The proposed solution is below. However, I don't really understand how line 4 works.
It says to go into fibonacci n-1 (which would be 8) which would go into 7 etc until 2, when it returns 1.
And the second element of the addition operation is fibonacci (n-2) (which would be 7) which would go into 6 etc until 2, when it returns 1.
So the result of this operation would be 2.
What am I missing?
public int fibonacci(int n) {
if (n == 1 || n == 2)
return 1;
else return fibonacci(n - 1) + fibonacci(n - 2);