odin-javascript-exercises/fibonacci/fibonacci.js
2017-12-15 11:01:24 -06:00

13 lines
227 B
JavaScript

const fibonacci = function(count) {
if (count < 0) return "OOPS";
let a = 0;
let b = 1;
for (let i = 1; i < count; i++) {
const temp = b;
b = a + b;
a = temp;
}
return b;
};
module.exports = fibonacci;