Monday, March 18, 2013

C#: Calculate the factorial of n


//Example 3. Write a program with a Console Application, the factorial of n raw keyboard input.
class Program
    {
        static void Main ()
        {
            int n;
            int GT = 1;
Console.Write ("Enter the number of n identity factorial:");
            n = int.Parse (Console.ReadLine ());
            for (int i = 2; i <= n; i + +)
                GT * = i;
            Console.WriteLine ("The factorial of {0} is: {1}", n, GT);
            Console.ReadLine ();
        }
    }

No comments:

Post a Comment