On Tue, 7 Feb 2017, at 03:36 PM, Tomi Häsä wrote:

> Is it normal to get 45 in the Flow Control example?

> 

> https://tour.golang.org/flowcontrol/1

> 

> package main

> 

> import "fmt"

> 

> func main() {

> sum := 0

> for i := 0; i < 10; i++ {

> sum += i

> fmt.Println(i)

> }

> fmt.Println(sum)

> }





The sum of integers up to n is n(n+1)/2  = 9*10/2 = 45, so it's what I
would expect.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to