Update fibonacci/fibonacci.js
top ! Co-authored-by: Eric Olkowski <70952936+thatblindgeye@users.noreply.github.com>
This commit is contained in:
parent
46c3c25d46
commit
cc0badd69c
|
@ -4,6 +4,9 @@ const fibonacci = function(count) {
|
||||||
let a = 0;
|
let a = 0;
|
||||||
let b = 1;
|
let b = 1;
|
||||||
for (let i = 1; i < count; i++) {
|
for (let i = 1; i < count; i++) {
|
||||||
|
const temp = b;
|
||||||
|
b = a + b;
|
||||||
|
a = temp;
|
||||||
// A slightly shorter version of the above solution:
|
// A slightly shorter version of the above solution:
|
||||||
// [a, b] = [b, a + b];
|
// [a, b] = [b, a + b];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue