mirror of
https://github.com/urbit/ares.git
synced 2024-11-22 15:08:54 +03:00
a7005c7049
* Update README.md * Rename ares -> sword * Workspace * Cargo-only CI
18 lines
344 B
Rust
18 lines
344 B
Rust
use ibig::UBig;
|
|
|
|
// a * (a+1) * ... * (b-1)
|
|
fn product(a: u32, b: u32) -> UBig {
|
|
if b == a + 1 {
|
|
UBig::from(a)
|
|
} else {
|
|
let mid = a + (b - a) / 2;
|
|
product(a, mid) * product(mid, b)
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let n: u32 = 1000000;
|
|
let factorial = product(1, n + 1);
|
|
println!("{}! = {:#x}", n, factorial);
|
|
}
|