Sum All Odd Fibonacci Numbers-with one failed

Sum All Odd Fibonacci Numbers-with one failed
0.0 0


Tell us what’s happening:
sumFibs(4000000) when num is equal to 4000000 .The test fail.

Your code so far

function sumFibs(num) {
  let sum = 0;
  function fib(e){// 1,1,2,3,5,8,13,21,34	
      return 1;
      return fib(e-1) + fib(e-2);

  for(let i=0;fib(i)<=num;i++){	
    if((fib(i)+1)%2 == 0){
  return sum;			

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:


I think you have misunderstood the problem presented here. They want you to add all the numbers up to the given num, but your for loop stops well short of that (because it stops when the sum reaches the given num).


I cut the code and put it in a blank html file and run it . it shows the right answer.confused


What answer do you get for 400000?


It’ll be timing out, you’re computing extremely large numbers using a brute force recursive method. Using an algorithm that doesn’t rely on that recursive function, or rewriting the recursive function to not be recursive should make the test pass.