피보나치 수

magicdrill·2025년 1월 20일
0

피보나치 수

class Solution {
    public int solution(int n) {
        int answer = 0;
        int i;
        long [] DP = new long[n + 1];
        
        DP[0] = 0;
        DP[1] = 1;
        for(i = 2; i <= n; i++){
            DP[i] = (DP[i-1] + DP[i-2]) % 1234567;
            System.out.print(DP[i] + " ");
        }
        answer = (int)DP[n];
        
        return answer;
    }
}

0개의 댓글