Challenge: Fibonacci Numbers
Let’s find the nth number in the Fibonacci series using recursion.
We'll cover the following
Problem
Find the number in the Fibonacci series using recursion.
The formula for the Fibonacci series is:
f(n) = f(n-1) + f(n-2)
For example, the Fibonacci series is
1, 1, 2, 3, 5, 8, and so on
Input
An integer.
Output
The number in the Fibonacci series.
Sample input
Fibonacci(10)
Sample output
10th number in Fibonacci series: 55
Coding exercise
Try to solve this yourself first. If you get stuck or need help, you can always press the “Show Solution” button to see how your problem can be solved. We’ll look at the solution in the next lesson.
Good luck!
Get hands-on with 1400+ tech skills courses.