import java.util.Scanner; public class Fibonacci { public static int fibonacci(int n) // precondition: n >= 1 // postcondition: the n^th Fibonacci number has been returned { if (n == 1 || n == 2) return 1; else return fibonacci(n-1) // number of pairs that were around in month n-1 // (they never die) + fibonacci(n-2); // number of newborn pairs, which is equal to the // number of pairs that were around in month n-2, // making them old enough to have a pair of babies // of their own in month n } public static void main(String[] args) { Scanner Input = new Scanner(System.in); System.out.print("Enter number of months: "); int n = Input.nextInt(); System.out.println("\n\nAfter " + n + " months there will be " + fibonacci(n) + " pairs of rabbits.\n"); } }