21 lines
191 B
JavaScript
21 lines
191 B
JavaScript
|
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);
|