백준 10872 팩토리얼
Console Programming/C# Console 2019. 12. 20. 09:10using System;
namespace _10872
{
class Program
{
static void Main(string[] args)
{
int num = int.Parse(Console.ReadLine());
int res = Factorial(num);
Console.WriteLine(res);
}
public static int Factorial(int n)
{
int result = n;
if(n==0)
{
return 1;
}
else if(n>1)
{
return result * Factorial(n - 1);
}
else
{
return result;
}
}
}
}
'Console Programming > C# Console' 카테고리의 다른 글
백준 2908 상수 (0) | 2020.04.02 |
---|---|
백준 1152 단어의 개수 (0) | 2020.04.02 |
4948 베르트랑 공준 (0) | 2019.12.04 |
1929 소수 구하기 에라토스테네스의 체 (0) | 2019.12.04 |
2581 소수 (0) | 2019.12.03 |