Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Numerics; //use for the BigInteger
- class Program
- {
- static void Main()
- {
- BigInteger t1 = BigInteger.Parse(Console.ReadLine());
- BigInteger t2 = BigInteger.Parse(Console.ReadLine());
- BigInteger t3 = BigInteger.Parse(Console.ReadLine());
- BigInteger n = BigInteger.Parse(Console.ReadLine());
- BigInteger final = 0;
- if (n==1)
- {
- final = t1;
- }
- else if (n == 2)
- {
- final = t2;
- }
- else if (n == 3)
- {
- final = t3;
- }
- for (BigInteger i = 0; i < n - 3; i++)
- {
- final = t1 + t2 + t3;
- t1 = t2;
- t2 = t3;
- t3 = final;
- }
- Console.WriteLine(final);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment