odin-default-js-exercises/fibonacci/fibonacci.js

14 lines
227 B
JavaScript
Raw Normal View History

2017-12-15 17:01:24 +00:00
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;
};
2017-08-25 19:29:48 +00:00
2017-12-15 17:01:24 +00:00
module.exports = fibonacci;