sandbox-js/projectE2.js

21 lines
191 B
JavaScript
Raw Normal View History

2023-01-22 02:28:58 +01:00
let pre = 0;
let cur = 1;
let aft;
let s = 0;
let cap = 4000000;
while (cur <= cap) {
aft = pre + cur;
pre = cur;
cur = aft;
if (cur % 2 == 0) {
s = s + cur;
}
}
console.log(s);