프로그래밍
프로그래머스 C# x만큼 간격이 있는 n개의 숫자(using System.Collections.Generic, List.Add)
노마드선샤인
2023. 1. 23. 23:18
728x90
using System.Collections.Generic;
public class Solution {
public long[] solution(long x, int n) {
long[] answer = new long[n];
List<long> list = new List<long>();
for(int i = 1;i<=n;i++)
{
list.Add(i*x);
}
for(int j = 0;j<n;j++)
{
answer[j] = list[j];
}
return answer;
}
}
728x90