[프로그래머스]x만큼 간격이 있는 n개의 숫자

mongs_Develop·2022년 4월 26일
0

Programmers-Level1-Java

목록 보기
2/30
post-thumbnail
  • 문제 & 예시
  • 소스코드
// x만큼 간격이 있는 n개의 숫자
public class test02 {
	public static void main(String[] args) {
		Solution2 sol = new Solution2();
		int x = 2;
		int n = 5; 
		System.out.println(sol.solution(x, n));
	}
}

class Solution2 {
    public long[] solution(int x, int n) {
        long[] answer = new long[n];
        for(int i=0;i<n;i++) {
        	answer[i] = (long)x*(i+1);     	
        }
//		System.out.println(Arrays.toString(answer));
        return answer;
    }
}
  • consol
profile
개 발 인생

0개의 댓글