/** * Recursive (slow) Fibonacci function implementation * * @author (Stefan Edelkamp) * @version (2013) */ public class Fibonacci { /** * Fibonacci * * @param n parameter for the method * @return the n-th Fibnacci Number */ public int f(int n) { return (n<=1) ? n : f(n-1) + f(n-2); } public int [] F = new int[100]; public int fib(int n) { if (n<=1) return 1; if (F[n]!=0) return F[n]; F[n-1] = fib(n-1); return F[n-2] + F[n-1]; } }