Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp170
- {
- class Program
- {
- static int printTribRec(int n)
- {
- if (n == 1 || n == 2)
- {
- return 1;
- }
- if (n == 3)
- {
- return 2;
- }
- else
- {
- return printTribRec(n - 1) +
- printTribRec(n - 2) +
- printTribRec(n - 3);
- }
- }
- public static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- for (int i = 1; i <= n; i++)
- {
- Console.Write(printTribRec(i)
- + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement