File tree 2 files changed +11
-11
lines changed
2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
- * A function to get Fibonacci value of given number
2
+ * A function to get nth Fibonacci number
3
3
* @param number The input integer
4
- * @return {number } Fibonacci value of `number`
5
- * @example fibonacciValue (4) => 3 | fibonacciValue (6) => 8
4
+ * @return {number } Fibonacci number of `number`
5
+ * @example nthFibonacci (4) => 3 | nthFibonacci (6) => 8
6
6
* @see https://en.m.wikipedia.org/wiki/Fibonacci_number
7
7
* @author MohdFaisalBidda <https://github.com/MohdFaisalBidda>
8
8
*/
9
9
10
- export const fibonacciValue = ( number : number ) : number => {
10
+ export const nthFibonacci = ( number : number ) : number => {
11
11
if ( number < 0 ) throw "Number should be greater than 0" ;
12
12
13
13
if ( number === 0 ) return 0 ;
Original file line number Diff line number Diff line change 1
- import { fibonacciValue } from '../Fibonacci' ;
1
+ import { nthFibonacci } from '../Fibonacci' ;
2
2
3
- describe ( 'FibonacciValue ' , ( ) => {
3
+ describe ( 'nthFibonacci ' , ( ) => {
4
4
5
5
test ( 'should return correct value' , ( ) => {
6
6
7
- expect ( fibonacciValue ( 0 ) ) . toBe ( 0 ) ;
8
- expect ( fibonacciValue ( 1 ) ) . toBe ( 1 ) ;
9
- expect ( fibonacciValue ( 5 ) ) . toBe ( 5 ) ;
10
- expect ( fibonacciValue ( 4 ) ) . toBe ( 3 ) ;
11
- expect ( fibonacciValue ( 0 ) ) . toBe ( 0 ) ;
7
+ expect ( nthFibonacci ( 0 ) ) . toBe ( 0 ) ;
8
+ expect ( nthFibonacci ( 1 ) ) . toBe ( 1 ) ;
9
+ expect ( nthFibonacci ( 5 ) ) . toBe ( 5 ) ;
10
+ expect ( nthFibonacci ( 4 ) ) . toBe ( 3 ) ;
11
+ expect ( nthFibonacci ( 0 ) ) . toBe ( 0 ) ;
12
12
13
13
} ) ;
14
14
} ) ;
You can’t perform that action at this time.
0 commit comments