programmers_피보나치 수_java
2023. 4. 3. 11:32ㆍAlgorithm/Programmers
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/12945
class Solution {
final int MOD = 1234567;
public int solution(int n) {
int answer = 0;
long[] fibo = new long[n+1];
fibo[0] = 0;
fibo[1] = 1;
fibo[2] = 1;
for(int i = 3; i<=n; i++){
fibo[i] = (fibo[i-1]+ fibo[i-2])%MOD;
}
answer = (int)fibo[n];
return answer;
}
}
'Algorithm > Programmers' 카테고리의 다른 글
programmers_짝지어 제거하기_java (0) | 2023.04.03 |
---|---|
programmers_다음 큰 숫자_java (0) | 2023.04.03 |
programmers_구명보트_java (0) | 2023.04.03 |
programmers_이진 변환 반복하기_java (0) | 2023.04.01 |
programmers_이진 변환 반복하기_java (0) | 2023.04.01 |