You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func main3() {
var n uint64
if *ngoroutines == 0 {
n = uint64(runtime.GOMAXPROCS(0))
} else {
n = uint64(*ngoroutines)
}
fmt.Println("GOMAXPROCS", n)
result := make(chan uint64)
var i uint64
for i = 0; i < n; i++ {
go func(i uint64) {
var sum uint64
var start = (LIMIT / n) * i
var end = start + (LIMIT / n)
for j := start; j < end; j++ {
sum += j
}
result <- sum
}(i)
}
var total uint64
for i = 0; i < n; i++ {
total += <-result
}
fmt.Println(total)
}
The text was updated successfully, but these errors were encountered:
vmanyushin
changed the title
see you post on reddit
saw your post on reddit
Oct 3, 2018
The text was updated successfully, but these errors were encountered: