작성
·
13
0
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
solution(in.nextInt(), 1, 1, 0);
in.close();
}
public static void solution(int target, int start, int value, int prevValue) {
if (target >= start) {
System.out.print(value + " ");
solution(target, start + 1, value + prevValue, value);
}
}
}
다음과 같이 풀어보았는데요, 재귀와 메모이제이션을 비슷하게 구현한것 같아서요.
이렇게 작성하면 어떨지 문의드려요!
답변