Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigInteger;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- BigInteger[] array = new BigInteger[5050];
- for (int i = 2; i < 5050; i++) {
- array[i] = array[i - 1] + array[ i - 2 ];
- }
- while (scan.hasNext()) {
- int x = scan.nextInt();
- System.out.println("The Fibonacci number for " + x + " is "
- + array[x - 2]);
- }
- }
- }
Add Comment
Please, Sign In to add comment