tranerius

рекурсия

Mar 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. class Test
  2. {
  3.     static int FactV(int value)
  4.     {
  5.         int result;
  6.         System.Console.WriteLine("Вызов метода для числа " + value);
  7.         if (value == 0)
  8.         {
  9.             System.Console.WriteLine("Возврат значения {0}!", value);
  10.             return 1;
  11.         }
  12.         result = FactV(value - 1) * value;
  13.         System.Console.WriteLine("Возврат значения {0}!", value);
  14.         return result;
  15.     }
  16.     static void Main()
  17.     {
  18.         System.Console.WriteLine(FactV(10));
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment