Advertisement
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 sc = new Scanner(System.in);
- int num = sc.nextInt();
- BigInteger f1 = BigInteger.ONE;
- BigInteger f0 = BigInteger.ZERO;
- if (num==0){ System.out.println(f0); }
- else{
- if (num==1){ System.out.println(f1); }
- else{
- for (int i = 1;i<=num;++i) {
- BigInteger f = f0.add(f1);
- f0 = f1;
- f1 = f;
- }
- System.out.println(f0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement