C#/C#200제
[C#] 7일차 - 48. 팩토리얼 구하기
반나무
2021. 1. 23. 09:39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A048_Factorial
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("n!를 계산합니다.");
Console.Write("n을 입력하세요 : ");
int n = int.Parse(Console.ReadLine());
int fact = 1;
for (int i = 2; i <= n; i++)
{
fact *= i;
}
Console.WriteLine("{0}! = {1}", n, fact);
}
}
}
반응형