Sha256: b379c34394cf0934298fcb833544579ceddc2e10e6cae129cac946ede4d54e5b
Contents?: true
Size: 562 Bytes
Versions: 49
Compression:
Stored size: 562 Bytes
Contents
struct SumOfMultiples { static func toLimit(_ limit: Int, inMultiples: [Int]) -> Int { var multiples = Set(inMultiples) if let indexOfZero = multiples.index(of: 0) { multiples.remove(at: indexOfZero) } var itemToReturn = 0 for each in 1..<limit { var lastAdded = 0 for multiple in multiples where ((each % multiple == 0) && (lastAdded != each)) { itemToReturn += each lastAdded = each } } return itemToReturn } }
Version data entries
49 entries across 49 versions & 1 rubygems