import java.math.BigInteger;
/*
* bhatt.umang7@gmail.com
*/
/**
* @author umang
*/
public class Fib
{
public static void main(String args[])
{
BigInteger prev_prev = new BigInteger("0");
BigInteger prev = new BigInteger("1");
BigInteger sum = prev_prev.add(prev);
long i = 1 ; // as 1 should already be there
while (sum.toString().length() < 1000)
{
sum = prev_prev.add(prev);
prev_prev = prev;
prev = sum;
i++;
System.out.println(i + " is " + sum.toString());
}
System.out.println(i);
}
}
|
No comments:
Post a Comment