DEV Community

Discussion on: Project Euler #2 - Even Fibonacci numbers

Collapse
 
crownedprinz profile image
Ademola John • Edited

Here was my solution in Javascript to the problem on Euler

function fiboEvenSum(n) { let previous = 0, current = 1, result = 0; for(let i = 0;i const next = previous + current; if(next % 2 ===0){ result += next; } if(next>n)break; previous = current; current = next; } return result; } fiboEvenSum(10);