Looping with while


#1

Hi!

Wondering why with the code below the loop doesn't end at the number '50'.
I understand that print has to come first to start with '1' instead of '2' , but why is '51' printed?
Thanks!

i = 1
while i <= 50 do
i += 1
print "#{i}"
end


#2

@vincentvi,
Try it with

i = 1
while i <= 50 do 
 print "#{i}"
 i += 1
end

where you increment i AFTER you print