package summultiples // MultipleSummer takes a variable number of ints // and returns a function that, when given a limit // returns the sum of the multiples up to that limit func MultipleSummer(mults ...int) func(int) int { return func(limit int) int { var ret int for i := range mults { sumMult := mults[i] for sumMult < limit { var skip bool for j := 0; j < i && !skip; j++ { // Make sure that we haven't already added sumMult if sumMult%mults[j] == 0 { skip = true } } if !skip { ret += sumMult } sumMult += mults[i] } } return ret } }