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