Guest User

Untitled

a guest
May 25th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. function evenFiboSum(ceilingValue) {
  2.  
  3. let sum = 0;
  4. let x = 1;
  5. let y = 2;
  6.  
  7. while (x <= ceilingValue) {
  8.  
  9. if (x % 2 == 0) {
  10. sum += x;
  11. }
  12.  
  13. y = x + y;
  14. x = y - x;
  15.  
  16. }
  17.  
  18. return sum;
  19. }
  20.  
  21. console.log(evenFiboSum(4000000));
Add Comment
Please, Sign In to add comment