// // example (simple) of the dynamic programming principle // also considere as "memoization // public class FibDP { private static int fib(int n){ int[] fib = new int[n+1]; fib[0] = 0; fib[1] = 1; for (int i=2;i<=n;i++) fib[i] = fib[i-1] + fib[i-2]; return fib[n]; } public static void main(String[] args) { int n = Integer.parseInt(args[0]); System.out.println(fib(n)); } }