Console Programming/C# Console
백준 10872 팩토리얼
폰타인
2019. 12. 20. 09:10
using 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;
}
}
}
}