Generating sequence that uses the previous outcome for the current
Using while would be idiomatic in almost any language. while is basically the way to iterate, uh, while a condition is true. Hence the name - it's practically plain English.

You can postfix the while and save a couple of lines, but that's about it

puts value = value**2 while value &lt; 10000


or use until if you want, but same difference

puts value = value**2 until value &gt;= 10000


If you were dealing with a fixed or known number of iterations, you could do something like

4.times.inject(2) do |memo, _|
  puts memo = memo ** 2
  memo
end


but the whole point here is really that you don't know the number of iterations.