I was asked this question for a JavaScript interview.
Implement fibonacci series to list the sequence up n numbers (n not included) where recursion happens only for even numbers. for example
fib(10) -> fib(8) + fib (6)
fib(8) -> fib(6) + fib(4)
fib(6) -> fib(4) +fib(2)
fib(4) -> fib(2)
I am not sure how to go about this.
Consideration
In code we get this - a nice little recursion (valid for all even n >= 0):
If you want a result like
fib(10) -> fib(8) + fib(6)
, then this will do it (no recursion):