// C# program to find factorial
// of given number
using System;
class Test {
// method to find factorial
// of given number
static int factorial(int n)
{
if (n == 0)
return 1;
return n * factorial(n - 1);
}
// Driver method
public static void Main()
{
int num = 5;
Console.WriteLine("Factorial of "
+ num + " is " + factorial(5));
}
}
// This code is contributed by vt_m
using System;
public class Program
{
public int findFact(int n)
{
int i, f = 1;
for (i = 1; i <= n; i++)
{
f = f * i;
}
return f;
}
public static void Main(string[] args)
{
int x, f;
Console.Write("Enter a number:");
x = Convert.ToInt32(Console.ReadLine());
Program obj = new Program();
f = obj.findFact(x);
Console.WriteLine("Factorial is:" + f);
}
}
int Factorial(int n)
{
if (n == 1) return 1;
return n * Factorial(n - 1);
}