find factorial to given number using recursion

Gow.Net
Posted by Gow.Net under C# category on | Points: 40 | Views : 1844
Find factorial to given number using recursion

 class Program
{
public static int resultl=1;
static int factorial(int x)
{
if (x <= 1)
return 1;
else

return x * factorial(x - 1);
}
static void Main(string[] args)
{
int no,fact=0;
Console.WriteLine("Enter the givennumber");
no = Convert.ToInt16(Console.ReadLine());
fact=factorial(no);
Console.WriteLine(fact);
Console.ReadKey();

}
}

Comments or Responses

Login to post response