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

김정현·2022년 12월 14일
0

프로그래머스

목록 보기
5/50

📚 Problem

x만큼 간격이 있는 n개의 숫자

💫 Solve

func solution(_ x:Int, _ n:Int) -> [Int64] {
    var arr : [Int64] = []
    for i in 1...n {
        arr.append(Int64(x*i))
    }
    return arr
}

🩺 Another Solution

func solution(_ x:Int, _ n:Int) -> [Int64] {
    return Array(1...n).map { Int64($0 * x) }
}
profile
🍎💻👍

0개의 댓글