0
when reaching num value to 1 then the method called again and and again with argument 0 (num-1) then how it is working
namespace SoloLearn { class Program { static int Fact(int num) { if (num == 1) { return 1; } return num * Fact(num - 1); } static void Main(string[] args) { Console.WriteLine(Fact(6)); } } }
1 Odpowiedź
+ 1
Try to put the "return num * Fact (num - 1)" into else block.