Advertisement
n4wn4w

NAKOV

Mar 18th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. nakov/////////////////////////////////////////////////////////////////////////////////////
  2.  BigInteger t1 = long.Parse(Console.ReadLine());
  3.             BigInteger t2 = long.Parse(Console.ReadLine())
  4.             BigInteger t3 = long.Parse(Console.ReadLine());
  5.  
  6.             int n = int.Parse(Console.ReadLine());
  7.  
  8.             BigInteger tn = 0;
  9.  
  10.             if (n == 1)
  11.             {
  12.                 Console.WriteLine(1);
  13.             }
  14.             else if (n == 2)
  15.             {
  16.                 Console.WriteLine(2);
  17.             }
  18.             else if (n == 3)
  19.             {
  20.                 Console.WriteLine(3);
  21.             }
  22.             else
  23.             {
  24.                 for (int i = 4; i <= n; i++)
  25.                 {
  26.                     tn = t1 + t2 + t3;
  27.                     t1 = t2;
  28.                     t2 = t3;
  29.                     t3 = tn;
  30.                 }
  31.             }
  32.             Console.WriteLine(tn);
  33.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement