[Swift 알고리즘] 하샤드 수

장주명·2021년 5월 14일

https://programmers.co.kr/learn/courses/30/lessons/12947

func solution(_ x:Int) -> Bool {
    
    let harshard = String(x).map {Int(String($0))!}.reduce(0, +)
        
    return x % harshard == 0
}
profile
flutter & ios 개발자

0개의 댓글