Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.math.BigInteger;
  3.  
  4. class Main {
  5. public static void main(String[] args) {
  6.  
  7. BigInteger[] fibo = new BigInteger[1005];
  8.  
  9. fibo[0] = BigInteger.valueOf(1);
  10. fibo[1] = BigInteger.valueOf(2);
  11.  
  12. for (int i = 2; i < 1005; i++)
  13. fibo[i] = fibo[i - 2].add(fibo[i - 1]);
  14.  
  15. Scanner sc = new Scanner(System.in);
  16. while (sc.hasNext()) {
  17. int n = sc.nextInt();
  18. System.out.println(fibo[n]);
  19. }
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement