using System;
using System.Collections.Generic;
using System.Text;

namespace Factorial
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, n, fac = 1;
            string s;
            Console.Write("Please enter any number to find it's factorial(0 to 19):\n");
            s = Console.ReadLine();
            n = Int32.Parse(s); 
            for (i = 1; i <= n; i++)
            {
                fac = fac * i;
            }
            Console.WriteLine("\nThe factorial of '{0}' is {1}.",n,fac);
            Console.Read();
        }
    }
}

INPUT/OUTPUT: 5/120

<snipped>

Attachments My_Pic.jpg 46.94 KB

c# syntax for factorial of the number
1.
using System;
2.
using System.Collections.Generic;
3.
using System.Text;
4.

5.
namespace Factorial
6.
{
7.
class Program
8.
{
9.
static void Main(string[] args)
10.
{
11.
double i, n ;
int fac = 1;
12.
string s;
13. Console.Write("Please enter any number to find it's factorial:\n");
14. s = Console.ReadLine();
15. n = Int32.Parse(s);
16. for (i = 1; i <= n; i++)
17. {
18. fac = fac * i;
19. }
20. Console.WriteLine("\nThe factorial of '{0}' is {1}.",n,fac);
21. Console.Read();
22. }
23. }
24. }

This article has been dead for over six months. Start a new discussion instead.