๐ฉ๐ปProgramming/Coding Test
[C#] [BOJ#10872] ํฉํ ๋ฆฌ์ผ
taesooya
2022. 8. 14. 15:02
https://www.acmicpc.net/problem/10872
10872๋ฒ: ํฉํ ๋ฆฌ์ผ
0๋ณด๋ค ํฌ๊ฑฐ๋ ๊ฐ์ ์ ์ N์ด ์ฃผ์ด์ง๋ค. ์ด๋, N!์ ์ถ๋ ฅํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค.
www.acmicpc.net
My Solution
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int result = n;
int i = n-1;
while (i > 0)
{
result = result * i;
i--;
}
Console.WriteLine(n == 0 ? 1 : result);
}
}
}