fibo

class FiboRec {
public int FibR(int n) {
 if (n <= 2) return 1;
 else
 return FibR(n - 1) + FibR(n - 2);
 }
 }
class FiboDP {
public int FibD(int m) {
 int F = new int[m];
 F[0] = F[1] = 1;
 for (int i = 2; i < m ; i++)
 F[i] = F[i-1] + F[i-2];
 return F[m-1];
 }
}
public class FiboTime {
 public static void main (String args){
 int n = Integer.parseInt(args[0]);
 FiboRec rec = new FiboRec();
 FiboDP  dp  = new FiboDP();
 double t1 = System.nanoTime();
 System.out.println("FiboRec " + n + "\n" + rec.FibR(n));
 double t2 = System.nanoTime();
 System.out.println*1;
 double s2 = System.nanoTime();
 System.out.println((s2 - s1)/1000000 + " ms" );
 }
}

*1:t2 - t1)/1000000 + " ms\n" );

 double s1 = System.nanoTime();
 System.out.println("FiboDP " + n + "\n" + dp.FibD(n