c#/백준알고리즘

[c#] 274333번 팩토리얼 2

Heeyeon Choi 2023. 12. 11. 16:50
728x90

https://www.acmicpc.net/problem/27433

 

27433번: 팩토리얼 2

0보다 크거나 같은 정수 N이 주어진다. 이때, N!을 출력하는 프로그램을 작성하시오.

www.acmicpc.net

 

<풀이>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace baekjoon27433
{
    internal class FileName
    {
        static void Main(string[] args)
        {
            long n= long.Parse(Console.ReadLine());
            Console.WriteLine(Facto(n));
        }

        public static long Facto(long num)
        {
            if(num == 0) return 1;
            return num*Facto(num - 1);
        }
    }
}

 

728x90

'c# > 백준알고리즘' 카테고리의 다른 글

[c#] 11659번 구간 합 구하기 4  (0) 2023.12.20
[백준 15652번 c#] N과 M (4)  (0) 2022.10.24
[백준 18258번 c#] 큐 2  (0) 2022.10.06
[백준 11399번 c#] ATM  (2) 2022.10.06
[백준 15649번 c#] N과 M  (0) 2022.10.05