Thursday 30 August 2012

c# program factorial of a number | factorial program code

How to write  factorial of a number

namespace factorial
{
class Program
{

static void Main(string[] args)
{
int i, fact = 1, n;
String no;
Console.WriteLine("Enter a number:");
no = Console.ReadLine();
n = Convert.ToInt32(no);
for (i = 1; i <= n; i++)
{
fact = fact * i;
}
Console.WriteLine("factorial is:" + fact);
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;

namespace factorial
{
class Program
{

static void Main(string[] args)
{
int i, fact = 1, n;
String no;
Console.WriteLine("Enter a number:");
no = Console.ReadLine();
n = Convert.ToInt32(no);
for (i = 1; i <= n; i++)
{
fact = fact * i;
}
Console.WriteLine("factorial is:" + fact);
Console.ReadLine();
}
}
}
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: