곽로그

[백준 10872]팩토리얼 본문

알고리즘/백준

[백준 10872]팩토리얼

일도이동 2020. 2. 26. 00:06
반응형
import java.util.Scanner;

public class Main {
	public static int factorial(int n) {
		if(n<=1) {
			return 1;
		}
		return n*factorial(n-1);
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n= in.nextInt();
		System.out.println(factorial(n));
	}
}
반응형

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

[백준 11729] 하노이의 탑  (0) 2020.02.26
[백준 2477] 별찍기 -10  (0) 2020.02.26
[백준 4949] 균형잡힌 세상  (0) 2020.02.05
[백준 2869] 달팽이는 올라가고 싶다  (0) 2020.02.02
[백준 1712] 손익분기점  (0) 2020.02.02
Comments