go-by-test/sum/sum.go

21 lines
287 B
Go

package sum
func Sum(numbers []int) int {
sum := 0
for _, number := range numbers {
sum += number
}
return sum
}
func SumAll(numbersToSum ...[]int) []int {
res := make([]int, len(numbersToSum))
for i, numbers := range numbersToSum {
res[i] = Sum(numbers)
}
return res
}