You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
417 B
17 lines
417 B
11 months ago
|
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;
|
||
|
}
|
||
|
}
|