Algorithm/프로그래머스

[Lv. 1] x만큼 간격이 있는 n개의 숫자

녱녱 2023. 4. 21.

class Solution {
    public long[] solution(int x, int n) {
        long[] answer = new long[n];
        long num = x;
        for(int i = 0; i < answer.length; i++){
            answer[i] = num;
            num += x;
        }
        return answer;
    }
}

댓글