How are you? 

Function: 

  f(0) = 1
  f(1) = 1
  f(n) = f(n-1) + f(n-2) 

Write program to calculate f(...)

Run it for f(10), f(20), f(100), ... 

--

public class One {
  public static void main(String[] args) {
    System.out.println( fun(10) ); // 1 1 2 3 5 8 13 21 34 55 89 
                                   // 0 1 2 3 4 5  6  7  8  9 10 
  }
  public static int fun(int index) {
    if (index == 0) return 1; 
    else if (index == 1) return 1; 
    else return fun(index-1) + fun(index-2); 
  }
}

--

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> java One 10
89
> java One 11
144
> java One 12
233
> java One 20
10946
> java One 30
1346269
> java One 31
2178309
> java One 32
3524578
> java One 40
165580141
> java One 41
267914296
> java One 42
433494437
> java One 43
701408733
> java One 44
1134903170
> java One 45
1836311903
> java One 46
-1323752223


--

public class One {
  public static void main(String[] args) {
    int n = Integer.parseInt(args[0]); 
    System.out.println( fun(n) );  // 1 1 2 3 5 8 13 21 34 55 89 
                                   // 0 1 2 3 4 5  6  7  8  9 10 
  }
  public static long fun(int index) {
    if (index == 0) return 1; 
    else if (index == 1) return 1; 
    else return fun(index-1) + fun(index-2); 
  }
}

--

public class One {
  public static void main(String[] args) {
    int n = Integer.parseInt(args[0]); 
    System.out.println( fun(n) );  // 1 1 2 3 5 8 13 21 34 55 89 
                                   // 0 1 2 3 4 5  6  7  8  9 10 
  }
  public static long fun(int index) {
    if (index == 0) return 1; 
    else if (index == 1) return 1; 
    else return fun(index-1) + fun(index-2); 
  }
}

--

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> java One 46
2971215073
> java One 47
4807526976
> java One 48
7778742049
> java One 49
12586269025


--

public class One {
  public static void main(String[] args) {
    int n = Integer.parseInt(args[0]); 
    System.out.println( fun(n) );  // 1 1 2 3 5 8 13 21 34 55 89 
                                   // 0 1 2 3 4 5  6  7  8  9 10 
  }
  public static long fun(int index) {
    if (index == 0) return 1; 
    else if (index == 1) return 1; 
    return funHelper(1, index, 1, 1); 
  }
  public static long funHelper(int location, 
                               int target, 
                               long a, 
                               long b) {
    if (location == target) return b; 
    else {
      return funHelper(location + 1, target, b, a + b);   
    }
  }
}

--

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> java One 10
89
> java One 20
10946
> java One 30
1346269
> java One 40
165580141
> java One 50
20365011074
> java One 60
2504730781961
> java One 70
308061521170129
> java One 80
37889062373143906
> java One 90
4660046610375530309
> java One 100
1298777728820984005
> java One 120
790376311979428689
> java One 300
9010910435053616553
> java One 500
4859788740867454402
> java One 1000
9079565065540428013
> java One 2000
-820905900187520670
> java One 1990
-3458880258505395759
> java One 1970
-2236652274821374846
> java One 1900
2141288501034094421
> java One 1920
-5427398992173118207


--

Keep the speed give me infinite precision. 

Homework 01 is asking for that.

--

import java.math.BigInteger; 

public class One {
  public static void main(String[] args) {
    String number = args[0]; 
    BigInteger n = new BigInteger(number); 
    System.out.println( n.add(new BigInteger("1")) ); 
  }
}

--