Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigInteger;
- import java.util.Scanner;
- import sun.rmi.runtime.NewThreadAction;
- public class tribonachi
- {
- public static void main(String[] args)
- {
- Scanner scan = new Scanner(System.in);
- BigInteger first = scan.nextBigInteger();
- scan.nextLine();
- BigInteger second = scan.nextBigInteger();
- scan.nextLine();
- BigInteger third = scan.nextBigInteger();
- scan.nextLine();
- int n = scan.nextInt();
- BigInteger tN = new BigInteger("0");
- for (int i = 0; i < n - 3; i++)
- {
- tN = first.add(second);
- tN = tN.add(third);
- BigInteger temp = tN;
- first = second;
- second = third;
- third = temp;
- }
- System.out.println(tN);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment