function square(state, n) if n < state then n = n + 1 return n, n * n end end for i, n in square,42,0 do print(i, n) end