Last active
January 1, 2024 22:10
-
-
Save diracdeltafunk/460b65f7a4ab7f309b7984366c594e3c to your computer and use it in GitHub Desktop.
Computes the number of conjugacy classes of 2023Γ2023 matrices with coefficients in the finite field π½β
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[dependencies] | |
num-bigint = "0.4.4" | |
num-traits = "0.2.17" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use num_bigint::{BigUint, ToBigUint}; | |
use num_traits::{One, Zero}; | |
fn divisors(n: usize) -> Vec<usize> { | |
let mut divs = Vec::new(); | |
for i in 1..n + 1 { | |
if n % i == 0 { | |
divs.push(i); | |
} | |
} | |
divs | |
} | |
fn main() { | |
const N: usize = 2023; | |
let mut c: [BigUint; N + 1] = std::array::from_fn(|_| BigUint::zero()); | |
for n in 1..N + 1 { | |
for d in divisors(n) { | |
c[n] += d.to_biguint().unwrap() * (BigUint::one() << (n / d)); | |
} | |
} | |
let mut b: [BigUint; N + 1] = std::array::from_fn(|_| BigUint::zero()); | |
b[0] = BigUint::one(); | |
for n in 1..N + 1 { | |
for k in 1..n { | |
b[n] += c[k].clone() * b[n - k].clone(); | |
} | |
b[n] += c[n].clone(); | |
b[n] /= n; | |
} | |
print!("{}", b[N]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Runs in about 500ms on my laptop. The output is