iliya87

Tribonacci

Mar 23rd, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2. using System.Numerics;
  3.  
  4. class Program
  5. {
  6.     static void Main()
  7.     {
  8.         int stopper = 1;
  9.         BigInteger firstn = BigInteger.Parse(Console.ReadLine());
  10.         BigInteger secondn = BigInteger.Parse(Console.ReadLine());
  11.         BigInteger thirdn = BigInteger.Parse(Console.ReadLine());
  12.         BigInteger T = firstn;
  13.         int linesn = int.Parse(Console.ReadLine());
  14.         Console.WriteLine(firstn);
  15.         Console.WriteLine(secondn + " " + thirdn);
  16.         for (int i = 2; i < linesn; i++)
  17.         {
  18.  
  19.             for (int j = 2; j <= i + 2; j++)
  20.             {
  21.                 T = firstn + secondn + thirdn;
  22.                 Console.Write(T + " ");
  23.                 firstn = secondn;
  24.                 secondn = thirdn;
  25.                 thirdn = T;
  26.             }
  27.             Console.WriteLine();
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment