반응형
public class Q_10872 {
public static int factorial(int i) {
if(i == 0) {
return 1;
}else {
return i * factorial(i-1);
}
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int num = Integer.parseInt(br.readLine());
System.out.println(factorial(num));
}
}
반응형
'Algorithm > 백준 문제풀이' 카테고리의 다른 글
백준 11053 - 가장 긴 증가하는 부분 수열(자바 구현) (0) | 2022.03.08 |
---|---|
백준 1676 - 팩토리얼 0의 개수(자바 구현) (0) | 2022.03.03 |
백준 6588 - 골드바흐의 추측(자바 구현) (0) | 2022.02.26 |
백준 10799 - 쇠막대기(자바 구현) (0) | 2022.02.22 |
백준 1929 - 소수 구하기(자바 구현) (0) | 2022.02.12 |