Slice sum
Go Loops
for + range
Flowchart (ISO 5807)
Source code
func sum(a []int) int {
s := 0
for _, x := range a {
s += x
}
return s
} for + range
func sum(a []int) int {
s := 0
for _, x := range a {
s += x
}
return s
}