Many recursive algorithms can be expressed using iteration. For instance, the greatest common denominator function can be written recursively:
def gdc (x, y)
return x if y == 0
return gdc(y, x%y)
end
or iteratively:
def gdc_iter (x, y)
while y != 0 do
x, y = y, x%y
end
re...