import Foundation
func solution(_ number:Int, _ limit:Int, _ power:Int) -> Int {
var attack = [Int](repeating: 0, count: number+1)
for i in 1...number {
var c = i
while c <= number {
attack[c] += 1
c += i
}
print(attack)
}
attack = attack.map { $0 > limit ? power : $0 }
return attack.reduce(0, +)
}
'프로그래머스 > Lv.1' 카테고리의 다른 글
[Swift] 나머지가 1이 되는 수 찾기 (0) | 2023.02.12 |
---|---|
[Swift] 나누어 떨어지는 숫자 배열 (0) | 2023.02.12 |
[Swift] 과일 장수 (0) | 2023.02.12 |
[Swift] 개인정보 수집 유효기간 (0) | 2023.02.12 |
[Swift] 가장 가까운 같은 글자 (0) | 2023.02.12 |