1// WARNING: The function assumes that 'fib(0)=0' and 'fib(1)=1'
2// Returns the number of the fibonacci sequence at index 'n'
3public static int fib(int n) {
4 if (n < 2) // No difference if '<' or '<=', because 'fib(2)=2'.
5 return n;
6 return fib(n-1) + fib(n-2); // Uses the recursion method for solving
7}