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
296 B

fn main() {
let mut a1 = 1;
let mut a2 = 2;
let mut sum = 0;
while a2 <= 4_000_000 {
if a2 % 2 == 0 {
sum += a2;
}
let a_new = a1 + a2;
a1 = a2;
a2 = a_new;
// println!("{}", a_new);
}
println!("{}", sum);
}