Challenge 3: Find nth Fibonacci Number
- Problem Statement
In this exercise, you have to write a recursive function fibonacci that takes a positive integer number n as a parameter and returns the nth Fibonacci term in that range.
- The Fibonacci Sequence is the series of numbers in which the next term is found by adding the two previous terms:
1, 1, 2, 3, 5, 8, 13, 21, 34, ...
Here , the number 1 is the first term, 1 is the second term, 2 is the third term and so on…
Input
an integer n
Output
nth fibonacci term
Sample Input
7
Sample Output
13
Coding Exercise
fn fibonacci(term: i32) -> i32 {
// Write code here
-1
}
Good luck! 🤞