Factorial Numbers
using
System;
namespace
factorial
{
class Program
{
static void Main(string[]
args)
{
int
num;
Console.WriteLine("Enter the value of Num=");
num = Convert.ToInt32(Console.ReadLine());
decimal
f = factorial(num);
Console.WriteLine(f);
Console.ReadKey();
}
static decimal factorial(int
n)
{
if
(n == 0)
return
1;
else
return
n*factorial(n - 1);
}
}
}
No comments:
Post a Comment