Advertisement
Spocoman

04. Tribonacci Sequence

Jan 30th, 2022
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System;
  2.  
  3. namespace TribonacciSequence
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int number = int.Parse(Console.ReadLine());
  10.             TribonacciSequence(number);
  11.         }
  12.         static void TribonacciSequence(int num)
  13.         {
  14.             int[] current = new int[num + 3];
  15.             current[0] = 1;
  16.             for (int i = 3; i < num + 3; i++)
  17.             {
  18.                 current[i] = current[i - 1] + current[i - 2] + current[i - 3];
  19.                 Console.Write($"{current[i]} ");
  20.             }
  21.         }
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement