public class Fibonacci2 { public static void main (String[] argv) { // Test case 1: int n = 5; int f = fibonacci (n); System.out.println ("f(" + n + ") = " + f); // Test case 2: n = 20; f = fibonacci (n); System.out.println ("f(" + n + ") = " + f); } static int fibonacci (int n) { // Base cases rolled into one: if (n <= 2) { return (n-1); } return ( fibonacci(n-1) + fibonacci(n-2) ); } }