
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication10
{
class Program
{
static int num;
static long factorial = 1;
static void facto()
{
Console.WriteLine("Enter the number limit should be less than 20");
num = Convert.ToInt16(Console.ReadLine());
if (num > 20)
{
Console.WriteLine("You exceed the limit ");
}
else
{
if (num < 0)
{
Console.WriteLine(num + " factorial not defined");
}
else
{
for (int i = 1; i <= num; i++)
factorial *= i;
Console.WriteLine("\n factorial of " + num + " is " + factorial);
}
}
}
static void Main(string[] args)
{
Console.WriteLine("www.promohack.blogspot.com");
Program.facto();
Console.ReadLine();
}
}
}
Thank You.
Comments
Post a Comment