diff --git a/045/main.rs b/045/main.rs new file mode 100644 index 0000000..195c06c --- /dev/null +++ b/045/main.rs @@ -0,0 +1,16 @@ +use std::collections::HashSet; + +fn main() { + let mut ps = HashSet::new(); + let mut hs = HashSet::new(); + let N = 500000u64; + for n in 1..N { hs.insert(n*(2*n-1)); } + for n in 1..N { ps.insert(n*(3*n -1)/2 ); } + for n in 286u64..N { + let tn = n * (n+1)/2; + if !hs.contains(&tn) { continue; } + if !ps.contains(&tn) { continue; } + println!("{}", tn); + break; + } +}