Mega Code Archive

 
Categories / Ruby / Range
 

An example of a for loop that prints out a times table (from 1 to 12) for the number 2

for i in 1..12   print "2 x " + i.to_s + " = ", i * 2, "\n" end