How to find factorial of given number in c# using recursive function
Hello all, In this program, we can get the factorial value of a number using the recursive function in c#
using System;
using System.Collections.Generic;
using System.Text;
namespace testconsole
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter a number");
int number = Convert.ToInt32(Console.ReadLine());
double factorial = factorial_RecursionValue(number);
Console.WriteLine("factorial of : " + number + " = " + factorial);
Console.ReadLine();
}
public static double factorial_RecursionValue(int number)
{
if (number == 1)
return 1;
else
return number * factorial_RecursionValue(number - 1);
}
}
}

Comments
Post a Comment