We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
function main() {
var t = parseInt(readLine());
var a = 0;
var arr = [1,2];
for(var a0 = 0; a0 < t; a0++){
var n = parseInt(readLine());
for(var i=2; i< n; i++){
var res = arr[i-1] + arr[i-2];
arr.push(res);
}
// console.log(arr)
for (var j =0 ; j
a+=arr[j];
}
}
console.log(a);
arr = [1, 2];
a=0;
}
}
Whats wrong in this code it only passes 1 test case ?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #2: Even Fibonacci numbers
You are viewing a single comment's thread. Return to all comments →
function main() { var t = parseInt(readLine()); var a = 0; var arr = [1,2]; for(var a0 = 0; a0 < t; a0++){ var n = parseInt(readLine()); for(var i=2; i< n; i++){ var res = arr[i-1] + arr[i-2]; arr.push(res); } // console.log(arr) for (var j =0 ; j
}
}
Whats wrong in this code it only passes 1 test case ?