Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Factorial
- {
- class Factorial
- {
- static void Main(string[] args)
- {
- int number = int.Parse(Console.ReadLine());
- var factorial = number;
- for(int i = 1; i < number; i++)
- {
- factorial = factorial * ( number - i );
- }
- Console.WriteLine(factorial);
- /* Second solution */
- //var n = int.Parse(Console.ReadLine());
- //var factorial = 1;
- //do
- //{
- // factorial = factorial * n;
- // n--;
- //} while(n > 1);
- //Console.WriteLine(factorial);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement