We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Sunday, June 7, 2015

  ->Write a program to find the factorial of input the given number Using Recursion method ?

class Program

{
static void Main(string[] args)

{ int n,fact;

Console.WriteLine("Enter the value");

n = int.Parse(Console.ReadLine());

fact = factorial(n);
Console.WriteLine("factorial number is: {0}",fact);

Console.ReadLine();

} static int factorial(int n)

{
if (n == 1)

return n;

else

return n *factorial(n - 1);

}   

}






No comments: