JAVA 코딩 알고리즘 연습/프로그래머스

프로그래머스 - x만큼 간격이 있는 n개의 숫자 / JAVA (자바) 코딩 알고리즘 연습

easpop 2023. 2. 9. 15:07
728x90
반응형

반응형
class Solution {
    public long[] solution(int x, int n) {
		long[] answer = new long[n];
		long a = x;
		
		answer[0] = x;
		for (int i = 1; i < n; i++) {
			a += x;
			answer[i] = a;
			
		}
        
        return answer;
    }
}
728x90
반응형