Skip to content

Commit 93e57b0

Browse files
merge: Add FibonacciNumber.js test case and update the decription of function. (TheAlgorithms#840)
1 parent f379475 commit 93e57b0

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

Dynamic-Programming/FibonacciNumber.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
// https://en.wikipedia.org/wiki/Fibonacci_number
2-
1+
/**
2+
* @function Fibonacci
3+
* @description Fibonacci is the sum of previous two fibonacci numbers.
4+
* @param {Integer} N - The input integer
5+
* @return {Integer} fibonacci of N.
6+
* @see [Fibonacci_Numbers](https://en.wikipedia.org/wiki/Fibonacci_number)
7+
*/
38
const fibonacci = (N) => {
49
// creating array to store values
510
const memo = new Array(N + 1)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { fibonacci } from '../FibonacciNumber'
2+
3+
describe('FibonacciNumber', () => {
4+
it('fibonacci of 0', () => {
5+
expect(fibonacci(0)).toBe(0)
6+
})
7+
8+
it('fibonacci of 1', () => {
9+
expect(fibonacci(1)).toBe(1)
10+
})
11+
12+
it('fibonacci of 10', () => {
13+
expect(fibonacci(10)).toBe(55)
14+
})
15+
16+
it('fibonacci of 25', () => {
17+
expect(fibonacci(25)).toBe(75025)
18+
})
19+
})

0 commit comments

Comments
 (0)