Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Numerics;
- namespace TribonacciTriangle
- {
- class TribonacciTriangle
- {
- static void Main()
- {
- List<BigInteger> tribonacciNums = new List<BigInteger>();
- for (int i = 0; i < 3; i++)
- {
- tribonacciNums.Add(BigInteger.Parse(Console.ReadLine()));
- }
- int lines = int.Parse(Console.ReadLine());
- Console.WriteLine(tribonacciNums[0]);
- Console.WriteLine("{0} {1}",tribonacciNums[1],tribonacciNums[2]);
- if (lines==2)
- {
- return;
- }
- else
- {
- BigInteger currentTrib;
- BigInteger firstTrib = tribonacciNums[0];
- BigInteger secondTrib = tribonacciNums[1];
- BigInteger thirdTrib = tribonacciNums[2];
- for (int i = 0; i < 220; i++)
- {
- currentTrib = firstTrib + secondTrib + thirdTrib;
- tribonacciNums.Add(currentTrib);
- firstTrib = secondTrib;
- secondTrib = thirdTrib;
- thirdTrib = currentTrib;
- }
- int currentTribIndex = 3;
- int currentLineLength = 3;
- for (int i = 0; i < lines-2; i++)
- {
- for (int k = 0; k < currentLineLength; k++)
- {
- Console.Write("{0} ",tribonacciNums[currentTribIndex]);
- currentTribIndex++;
- }
- Console.WriteLine();
- currentLineLength++;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment