java41 재귀 함수 package ex06; public class Ex19 { public static void main(String[] args) { int result = fact(5); System.out.println(result); } public static int fact(int num) { if(num>0) return 2 * fact(num-1); else return 1; } } 문제는 숫자 2를 5번 곱하게 하는것이다. 이것을 팩토리얼로 구하는 방법이다. 2024. 1. 16. 이전 1 ··· 8 9 10 11 다음