Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Factorial
- {
- static void Main()
- {
- Console.Write("n = ");
- uint n = UInt32.Parse(Console.ReadLine());
- Console.Write("{0}! = ", n);
- // "decimal" is the biggest integer type
- decimal factorial = 1;
- // Perform an infinite loop
- while (true)
- {
- Console.Write(n);
- if (n == 1)
- {
- break;
- }
- Console.Write(" * ");
- factorial *= n;
- n--;
- }
- Console.WriteLine(" = {0}", factorial);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment