UVa : 10334


import java.math.BigInteger;
import java.util.Scanner;

/**
 *
 * @author Shahab
 */
public class Main {

      public static void main(String[] args) {
            // TODO code application logic here
            BigInteger fibo [] = new BigInteger [1000 + 5];
            fibo [0] = BigInteger.ONE;
            fibo [1] = BigInteger.valueOf(2);

            for ( int i = 2; i < 1002; i++ ) {
                  fibo [i] = fibo [i - 1].add(fibo [i - 2]);
            }

            Scanner input = new Scanner (System.in);

            while ( input.hasNextInt() ) {
                  int number = input.nextInt();
                  System.out.println (fibo [number]);
            }
      }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s