January 2018
Intermediate to advanced
332 pages
7h 36m
English
We can use recursion to generate Fibonacci series as follows:
function recursiveFibonacci(num) { if (num == 0) { return 0; } else if (num == 1 || num == 2) { return 1; } else { return recursiveFibonacci(num - 1) + recursiveFibonacci(num - 2); }}
You can see that we apply the same concept as earlier, that the next number is a summation of the two previous numbers of the Fibonacci series numbers. However, we are relying on recursion to recalculate all the old values as and when a new value is demanded.
Read now
Unlock full access