- Today
- Total
Notice
Recent Posts
Codemental
[baekjoon][Java] 10872번 - 팩토리얼 본문
반응형
문제
제출답안 (2022.07.22)
import java.io.*;
public class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
System.out.println(factorial(N, 1));
}
public static int factorial(int N, int result) {
if(N == 0) {
return 1;
}
result *= N;
N--;
if(N == 0) {
return result;
}else {
return factorial(N, result);
}
}
}
채점결과 (2022.07.22)
'Java > 코딩테스트(baekjoon)' 카테고리의 다른 글
[baekjoon][Java] 10870번 - 피보나치 수 5 (0) | 2022.07.22 |
---|---|
[baekjoon][Java] 17478번 - 재귀함수가 뭔가요? (0) | 2022.07.22 |
[baekjoon][Java] 15596번 - 정수 N개의 합 (0) | 2022.07.22 |
[baekjoon][Java] 11021번 - A+B - 7 (0) | 2022.07.22 |
[baekjoon][Java] 2742번 - 기찍 N (0) | 2022.07.22 |