/** * Compute the Fibonacci number in an inefficient way using recursion. * @param n number to computer the Fibonacci equivalent of, * index into the Fibonacci sequence. * @return Fibonacci number. * Fibonacci sequence: each number is sum of previous two: 1 1 2 3 5 8 */ public static int fibonacci( int n ) { if ( n < 0 ) { return 0; } else if ( n <= 1 ) { return 1; } else { // recursion eventutally terminates, with fibonacci(1) + fibonacci(0); return fibonacci( n - 1 ) + fibonacci( n - 2 ); } }