diff --git a/src/baekjoon/step/combinatoric/PROB10872.java b/src/baekjoon/step/combinatoric/PROB10872.java new file mode 100644 index 0000000..4e8b008 --- /dev/null +++ b/src/baekjoon/step/combinatoric/PROB10872.java @@ -0,0 +1,25 @@ +package baekjoon.step.combinatoric; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class PROB10872 { + public static int factorial(int n) { + // base case + if(n == 0) { + return 1; + } else { + 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()); + + System.out.println(factorial(N)); + + } + +} diff --git a/src/baekjoon/step/combinatoric/PROB10872.py b/src/baekjoon/step/combinatoric/PROB10872.py new file mode 100644 index 0000000..c7a5d87 --- /dev/null +++ b/src/baekjoon/step/combinatoric/PROB10872.py @@ -0,0 +1,15 @@ +# 팩토리얼을 재귀함수로 짜보자 + + +# 재귀함수 +def factorial(N): + if N == 0: + return 1 + + return N * factorial(N-1) + +# N 을 입력받자 +N = int(input()) + +# 결과를 출력해보자 +print(factorial(N))