What sum does this Go for loop print?
total := 0
for i := 1; i <= 1; i++ { total += i }
fmt.Println(total)Answer & explanation
Answer: 1
The loop adds all integers from 1 through n.
Practice control flow with self-contained questions. Check your answer, then use the explanation to understand the reasoning.
total := 0
for i := 1; i <= 1; i++ { total += i }
fmt.Println(total)Answer: 1
The loop adds all integers from 1 through n.