use num_bigint::BigUint; use num_traits::{Zero, One}; // Calculate large fibonacci numbers. fn fc(n: usize) -> BigUint { let mut nn = n; let mut res: BigUint = One::one(); while nn > 1 { res *= nn; nn-=1; } return res; } fn bn(n: usize, r: usize) -> BigUint { return fc(n) / (fc(r) * fc(n-r)); } fn main() { //println!("Hello, world!"); //println!("fib(1000) = {}", fib(1000)); let mut count = 0; for n in 1..=100 { for r in 1..=n { if bn(n, r) > BigUint::from(1000000u32) { count +=1; } } } println!("{}", count); }