Advertisement
4valeri

Problem_2___Tribonacci

Feb 20th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Numerics
  7.  
  8. namespace Problem_2___Tribonacci
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             long t1 = long.Parse(Console.ReadLine());
  15.             long t2 = long.Parse(Console.ReadLine());
  16.             long t3 = long.Parse(Console.ReadLine());
  17.  
  18.             decimal n = decimal.Parse(Console.ReadLine());
  19.  
  20.             long tn = 0;
  21.             for (int i = 4; i <= n; i++)
  22.             {
  23.                  tn = t1 + t2 + t3;
  24.                 t1 = t2;
  25.                 t2 = t3;
  26.                 t3 = tn;
  27.  
  28.  
  29.             }
  30.  
  31.             Console.WriteLine(tn);
  32.  
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement