Let's now get into the code and write the recursive solution for finding the Fibonacci number.
Okay, so we are given n over here.
Now the base case would be that if n is less than or equal to one, then we can just return n itself,
right?
Because if n is zero then we just return zero.
And if n is one, we just return one because we know that the Fibonacci series goes like that, right?
We have zero, then we have one, then we have zero plus one, which is one.
Then we have one plus one which is two, and the next one would be one plus two which is three.
And it goes on in this manner.
Okay.
So the base case over here is if n is less than or equal to one, then we can just return n itself.
Now if this is not the case then we can return Fibonacci n minus one plus Fibonacci n minus two.
Okay.
So for that we will be recursively calling the fib function with the inputs n minus one and n minus
two.
Okay.
So that's it.
Now this is the recursive solution.
Now let's go ahead and run this code and see if it's passing all the test cases okay.
So this is the recursive case.
So let's run it.
And you can see that it's passing all the test cases.