This may be a simple thing I can't see for some reason but I am going through the golang tour and in the "For continued" section and I was wondering if someone could explain to me how the logic executes and delivers the statement to be 1024. https://tour.golang.org/flowcontrol/2
package main
import "fmt"
func main() {
sum := 1
for ; sum < 1000; {
sum += sum
}
fmt.Println(sum)
}
Its really just doing powers of 2
so the outputs are
1 2 4 8 16 32 ... 1024
Think of this loop as
sum = 1
while(sum < x) {
sum = sum * 2
}