Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Numerics;
- namespace Tribonacci
- {
- class Tribonacci
- {
- static void Main(string[] args)
- {
- BigInteger num1 = int.Parse(Console.ReadLine());
- BigInteger num2 = int.Parse(Console.ReadLine());
- BigInteger num3 = int.Parse(Console.ReadLine());
- uint n = uint.Parse(Console.ReadLine());
- BigInteger nextNum = 0;
- if (n == 1)
- {
- nextNum = num1;
- Console.WriteLine(nextNum);
- }
- else if (n == 2)
- {
- nextNum =num2 ;
- Console.WriteLine(nextNum);
- }
- else if (n ==3)
- {
- nextNum = num3;
- Console.WriteLine(nextNum);
- }
- else
- {
- for (int i = 0; i < n - 3; i++)
- {
- nextNum = num1 + num2 + num3;
- num1 = num2;
- num2 = num3;
- num3 = nextNum;
- }
- Console.WriteLine(nextNum);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement