[백준] 27433. 팩토리얼2

2025. 10. 10. 17:04CS&알고리즘/백준

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

 

 

문제 풀이

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    static long factorial(int n) {
        if (n <= 1) return 1;

        return n * factorial(n - 1);
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        br.close();

        long factorial = factorial(n);
        System.out.println(factorial);
    }
}

 

'CS&알고리즘 > 백준' 카테고리의 다른 글

[백준] 10870. 피보나치수 5  (0) 2025.10.10
[백준] 2745. 진법 변환  (0) 2025.09.02