Guest User

Untitled

a guest
Oct 19th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. import java.math.BigInteger;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5. public static void main(String[] args) {
  6. Scanner scan = new Scanner(System.in);
  7. BigInteger[] array = new BigInteger[5050];
  8. for (int i = 2; i < 5050; i++) {
  9. array[i] = array[i - 1] + array[ i - 2 ];
  10. }
  11. while (scan.hasNext()) {
  12. int x = scan.nextInt();
  13. System.out.println("The Fibonacci number for " + x + " is "
  14. + array[x - 2]);
  15. }
  16. }
  17.  
  18. }
Add Comment
Please, Sign In to add comment