Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Factorial
- {
- class Program
- {
- static void Main(string[] args)
- {
- int factorial;
- while (!int.TryParse(Console.ReadLine(), out factorial))
- {
- Console.WriteLine("Invalid number entered");
- }
- int result = 0;
- bool hit = true;
- for (int i = factorial - 1; i > 0; i--)
- {
- if (hit)
- {
- result = factorial;
- hit = false;
- }
- result *= i;
- }
- Console.WriteLine(result);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement