using System;
using System.Collections.Generic;using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace factorial
{
Class Program
{
static void main(string[] args)
{ int fact = 1, i, n;
Console.WriteLine("Input any number.");
n = Convert.Toint32(Console.ReadLine());
if( n == 0)
{
Console.WriteLine("The factorial of 0 is 1.");
Console.ReadLine();
}
else
{
for(i=1; i<=n; i++)
{
fact = fact*i;
}
Console.WriteLine("The factorial of a given number is: {0}", fact);
Console.ReadLine();
}
}
}
}
OUTPUT:
Input any number.
5
The factorial of a given number is: 120
Comments
Post a Comment