In this code snippet enter any number and you can find the factorial of that number up to 40.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication30
{
class Program
{
static void Main(string[] args)
{
Class2 class22 = new Class2();
class22.factorial();
Console.ReadKey();
}
}
}
This is a program through which you can find the factorial of a number....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication30
{
public abstract class Class1
{
public abstract void factorial();
}
public class Class2 : Class1
{
public override void factorial()
{
Console.WriteLine("enter a number to find the factorial: ");
int n = Convert.ToInt32(Console.ReadLine());
long fact = 1;
for (int i = 1; i <= n; i++)
{
fact = fact * i;
}
Console.WriteLine("The factorial: {0}", fact);
}
}
}