/**
*
* Ashish Patel
* e: ashishsushilPatel@gmail.com
* w: https://ashish.me
*
*/
// Return the nth fibonocci number
// fib(1) == 1
// fib(2) == 1
// fib(n) = fib(n-1) + fib(n-2)
function fibonocci(value) {
if(value == 1 || value == 2){
return 1
}
return fibonocci(value - 1) + fibonocci(value - 2)
}
test('fibonocci', () => {
expect(fibonocci(6)).toEqual(8)
});
Created 2019-12-02T02:42:51+05:30 · Edit