프로그래머스/Lv.0

[Swift] 짝수의 합

물복딱복준복 2023. 2. 7. 23:58

import Foundation

func solution(_ n:Int) -> Int {
    return (0...n).filter { $0 % 2 == 0 }.reduce(0, +)
}