We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This is the basic introduction to the recurssion chapter and probably this problem is always first approached when someone tries to present this topic.
As with every recursion problem you need to cover your base cases and end the recursive stack. For this problem, the base case is different than your usual Fibonacci problem, but should not be to hard to code.
Here's how it would look like in Scala:
Fibonacci Numbers
You are viewing a single comment's thread. Return to all comments →
This is the basic introduction to the recurssion chapter and probably this problem is always first approached when someone tries to present this topic. As with every recursion problem you need to cover your base cases and end the recursive stack. For this problem, the base case is different than your usual Fibonacci problem, but should not be to hard to code. Here's how it would look like in Scala: