Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. // The solution is so simple(not easy) compared to other solutions, my brains hurts, but proud of my work!
  2.  
  3. function sumFibs(n, a = 0, b = 1) {
  4. if (a > n) return 0;
  5. if (a % 2 !== 0) return a + sumFibs(n, a + b, a);
  6. else return 0 + sumFibs(n, a + b, a);
  7. }
  8. sumFibs(10); //1 + 1 + 3 + 5 = 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement