Watch a for loop execute step by step. The loop invariant sum = 0 + 1 + ... + (i-1) is maintained at each iteration.
for
sum = 0 + 1 + ... + (i-1)
Watch a closure capture a shared environment cell. Two functions created in the same scope share the same variable n.
n