코딩테스트/백준
[백준-자바] 10872번 팩토리얼 / 2022.03.22
강원대목동녀
2022. 3. 22. 14:12
https://www.acmicpc.net/problem/10872
import java.util.Scanner;
public class Main {
public static int factorial(int n){
if(n<=1) // 0!은 1
return 1;
return n*factorial(n-1);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
System.out.println(factorial(N));
}
}