node-versions/tests/simple-test.js

15 lines
228 B
JavaScript
Raw Normal View History

function fibonacci(num){
var a = 1, b = 0, temp;
while (num >= 0){
temp = a;
a = a + b;
b = temp;
num--;
}
return b;
}
console.log(fibonacci(7));
console.log(fibonacci(23));