Sha256: 803b54f7abb80b043b58c33236d229d336f3902207b66d623f9dff9cc23d99e3

Contents?: true

Size: 320 Bytes

Versions: 199

Compression:

Stored size: 320 Bytes

Contents

package summultiples

// SumMultiples returns the sum of the multiples of the given divisors
// up to, but not including, the given limit.
func SumMultiples(limit int, divisors ...int) (sum int) {
	for i := 1; i < limit; i++ {
		for _, d := range divisors {
			if i%d == 0 {
				sum += i
				break
			}
		}
	}
	return
}

Version data entries

199 entries across 199 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.179 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.178 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.177 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.176 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.175 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.174 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.173 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.172 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.171 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.170 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.169 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.167 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.166 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.165 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.164 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.163 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.162 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.161 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.160 tracks/go/exercises/sum-of-multiples/example.go