Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

main

[Java] 팩토리얼 (재귀호출) 본문

Java

[Java] 팩토리얼 (재귀호출)

1984 2022. 11. 11. 14:30

 

public class Factorial {

	private static int fact(int i) {
		if (i > 1) {
			return i * fact(i - 1);
		} else {
			return i;
		}
	}

	public static void main(String[] args) {
		int input = 10;
		System.out.println(fact(input));
	}

}
728x90
Comments