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();
}
}
}
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();
}
}
}
0 comments: