Advertisement
svetlyoek

Untitled

Feb 15th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp170
  4. {
  5. class Program
  6. {
  7. static int printTribRec(int n)
  8. {
  9.  
  10. if (n == 1 || n == 2)
  11. {
  12. return 1;
  13. }
  14. if (n == 3)
  15. {
  16. return 2;
  17. }
  18. else
  19. {
  20. return printTribRec(n - 1) +
  21. printTribRec(n - 2) +
  22. printTribRec(n - 3);
  23. }
  24. }
  25.  
  26.  
  27.  
  28.  
  29.  
  30. public static void Main()
  31. {
  32. int n = int.Parse(Console.ReadLine());
  33. for (int i = 1; i <= n; i++)
  34. {
  35. Console.Write(printTribRec(i)
  36. + " ");
  37. }
  38.  
  39.  
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement