Skip to content

Commit bec673a

Browse files
Changed the function name Fibonacci to nthFi onacci
1 parent a829b2d commit bec673a

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Maths/Fibonacci.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/**
2-
* A function to get Fibonacci value of given number
2+
* A function to get nth Fibonacci number
33
* @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
66
* @see https://en.m.wikipedia.org/wiki/Fibonacci_number
77
* @author MohdFaisalBidda <https://github.com/MohdFaisalBidda>
88
*/
99

10-
export const fibonacciValue = (number: number): number => {
10+
export const nthFibonacci = (number: number): number => {
1111
if (number < 0) throw "Number should be greater than 0";
1212

1313
if (number === 0) return 0;

Maths/test/Fibonacci.test.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import {fibonacciValue} from '../Fibonacci';
1+
import {nthFibonacci} from '../Fibonacci';
22

3-
describe('FibonacciValue', () => {
3+
describe('nthFibonacci', () => {
44

55
test('should return correct value', () => {
66

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);
1212

1313
});
1414
});

0 commit comments

Comments
 (0)