fibo40.java (499B)
1 import java.math.BigInteger; 2 3 class fibo40 { 4 5 final static BigInteger one = BigInteger.ONE; 6 final static BigInteger two = BigInteger.ONE.add(one); 7 final static BigInteger three = BigInteger.ONE.add(two); 8 9 final static BigInteger fibo(BigInteger n) { 10 if(-1 == n.compareTo(three)) return n; 11 else return fibo(n.subtract(one)).add(fibo(n.subtract(two))); 12 } 13 14 public static void main(String args[]) { 15 System.out.println(fibo(new BigInteger("40"))); 16 } 17 }