1
Answer

query about recursion function

kalpana jaiswal

kalpana jaiswal

8y
330
1
<ol><li><span>using System; </span> </li><li> <br /></li><li><span>namespace InterviewQuestionPart4 </span> </li><li>{ </li><li> <span>class Program </span> </li><li> { </li><li> <span>static void Main(string[] args) </span> </li><li> { </li><li> Console.WriteLine(<span>"Please Enter a Number"); </span> </li><li> <br /></li><li> <span>//read number from user </span> </li><li> <span>int number =Convert.ToInt32(Console.ReadLine()); </span> </li><li> <br /></li><li> <span>//invoke the static method </span> </li><li> <span>double factorial = Factorial(number); </span> </li><li> <br /></li><li> <span>//print the factorial result </span> </li><li> Console.WriteLine(<span>"factorial of"+number+"="+factorial.ToString()); </span> </li><li> <br /></li><li> } </li><li> <span>public static double Factorial(int number) </span> </li><li> { </li><li> <span>if (number == 0) </span> </li><li> <span>return 1; </span> </li><li> <span>return number * Factorial(number-1);//Recursive call </span> </li><li> <br /></li><li> } </li><li> } </li><li>} <br /></li></ol>in the above program when condition is satisfied then its should return 1as output then how the result is return?

Answers (1)