19 lines
209 B
Go
19 lines
209 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
func sum(numbers ...int) int {
|
|
var sum = 0
|
|
|
|
for _, number := range numbers {
|
|
sum += number
|
|
}
|
|
|
|
return sum
|
|
}
|
|
|
|
func main() {
|
|
fmt.Println(sum(4, 1, 9, 2))
|
|
fmt.Println(sum(7))
|
|
}
|