merge: Add FibonacciNumber.js test case and update the decription of function. (#840)

This commit is contained in:
YATIN KATHURIA
2021-11-20 16:21:25 +05:30
committed by GitHub
parent f379475723
commit 93e57b0de5
2 changed files with 26 additions and 2 deletions

View File

@ -1,5 +1,10 @@
// https://en.wikipedia.org/wiki/Fibonacci_number
/**
* @function Fibonacci
* @description Fibonacci is the sum of previous two fibonacci numbers.
* @param {Integer} N - The input integer
* @return {Integer} fibonacci of N.
* @see [Fibonacci_Numbers](https://en.wikipedia.org/wiki/Fibonacci_number)
*/
const fibonacci = (N) => {
// creating array to store values
const memo = new Array(N + 1)

View File

@ -0,0 +1,19 @@
import { fibonacci } from '../FibonacciNumber'
describe('FibonacciNumber', () => {
it('fibonacci of 0', () => {
expect(fibonacci(0)).toBe(0)
})
it('fibonacci of 1', () => {
expect(fibonacci(1)).toBe(1)
})
it('fibonacci of 10', () => {
expect(fibonacci(10)).toBe(55)
})
it('fibonacci of 25', () => {
expect(fibonacci(25)).toBe(75025)
})
})