This question already has an answer here:
- For loop of two variables in Go 2 answers
I was playing with for loop in Go via Go tour
When I ran
package main
import "fmt"
func main() {
sum := 1
for sum < 1000 {
sum += sum
}
fmt.Println(sum)
}
Program runs fine with output 1024
But when I change sum := 0
package main
import "fmt"
func main() {
sum := 0
for sum < 1000 {
sum += sum
}
fmt.Println(sum)
}
It gives error saying
process took too long
Program exited.
EDIT: I dived myself so deep into Go tour that I could not realise, I am making a logical error :P.
</div>