(Python, Java) 프로그래머스 - x만큼 간격이 있는 n개의 숫자
in Algorithm on Programmers, Level1
[문제 링크]
풀이
def solution(x, n):
return [x + x * multi for multi in range(n)]
Java 풀이
class Solution {
public long[] solution(int x, int n) {
long[] answer = new long[n];
long num = x;
for (int idx = 0; idx < n; idx++) {
answer[idx] = num;
num += x;
}
return answer;
}
}