diff --git a/10_fibonacci/fibonacci.js b/10_fibonacci/fibonacci.js index bb2c8cc..fb278ac 100644 --- a/10_fibonacci/fibonacci.js +++ b/10_fibonacci/fibonacci.js @@ -1,5 +1,11 @@ -const fibonacci = function() { - +const fibonacci = function(number, b) { + let sum; + for (let i = 0, a = 1, b = 1; + i < number - 2; + i++, (i % 2 == 0) ? a = sum : b = sum) { + sum = a + b; + } + return sum; }; // Do not edit below this line diff --git a/10_fibonacci/fibonacci.spec.js b/10_fibonacci/fibonacci.spec.js index de632d8..caedfdf 100644 --- a/10_fibonacci/fibonacci.spec.js +++ b/10_fibonacci/fibonacci.spec.js @@ -4,16 +4,16 @@ describe('fibonacci', () => { test('4th fibonacci number is 3', () => { expect(fibonacci(4)).toBe(3); }); - test.skip('6th fibonacci number is 8', () => { + test('6th fibonacci number is 8', () => { expect(fibonacci(6)).toBe(8); }); - test.skip('10th fibonacci number is 55', () => { + test('10th fibonacci number is 55', () => { expect(fibonacci(10)).toBe(55); }); - test.skip('15th fibonacci number is 610', () => { + test('15th fibonacci number is 610', () => { expect(fibonacci(15)).toBe(610); }); - test.skip('25th fibonacci number is 75025', () => { + test('25th fibonacci number is 75025', () => { expect(fibonacci(25)).toBe(75025); }); test.skip('0th fibonacci number is 0', () => {