Sha256: 1368059522c28d376a2d13e0979f360149bb7415c4127ce8a14421aa6210bb65

Contents?: true

Size: 343 Bytes

Versions: 92

Compression:

Stored size: 343 Bytes

Contents

package summultiples

const testVersion = 2

// 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

92 entries across 92 versions & 1 rubygems

Version Path
trackler-2.2.1.56 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.55 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.54 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.53 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.52 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.51 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.50 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.49 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.48 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.47 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.46 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.45 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.44 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.43 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.42 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.41 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.40 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.39 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.38 tracks/go/exercises/sum-of-multiples/example.go
trackler-2.2.1.37 tracks/go/exercises/sum-of-multiples/example.go