...

/

Solution Review 3: Find nth Fibonacci Number

Solution Review 3: Find nth Fibonacci Number

This lesson gives a detailed review of the challenge in the previous lesson.

We'll cover the following...

Solution:

Press + to interact
fn fibonacci(term: i32) -> i32 {
match term {
0 => 0,
1 => 1,
_ => fibonacci(term-1) + fibonacci(term-2),
}
}
fn main(){
println!("fibonacci(4)={}",fibonacci(4));
}

Explanation

A recursive ...

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy