// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
public class Fib {
    public static int fib(int n) {
        return n < 2 ? n : fib(n - 1) + fib(n - 2);
    }
    private static final int REP = 5;
    public static void main(String[] args) {
        System.out.println("Java:");
        for(int i = 0; i < REP; i++) {
            long t0 = System.currentTimeMillis();
            int ans = fib(45);
            long t1 = System.currentTimeMillis();
            System.out.printf("fib(45) = %d took %f seconds.\n", ans, (t1 - t0) / 1000.0);
        }
    }
}
