Question: How many pairs of rabbits are there after n years ?
Recursive solution for computing Fibonacci number f_{n}:
Fibonacci:
public static int fibonacci(int N) { int sol1, sol2; // Contain solutions for the smaller problems int solX; // Contains solution for original problem. if (N == 0) { // Base case 1 return(1); // Return solution } else if (N == 1) { // Base case 2 return(1); // Return solution } else { // Recursive solver sol1 = fibonacci(N1); // Solve smaller sub problem 1 sol2 = fibonacci(N2); // Solve smaller sub problem 2 solX = sol1 + sol2; // How to use solutions from // the smaller problems to solve // the original problem return(solX); // Return the solution.... } } 
Example: Fibonacci(3)
