From: Peter Hickman Date: 2012-02-08T21:04:28+09:00 Subject: Re: Count the numbers in a loop Well there is this then def f n ... yadda yadda yadda end counter = 0 num = gets.to_i while num > 1 num = f(num) puts num counter += 1 end puts "There were #{counter} numbers displayed" Also your comments are a waste of time. They convey nothing that the code does not and in one case is plain wrong. The program does not loop infinitely, it will terminate when num reaches 1 (and by the way the syracuse formula - as this is known - will always terminate, it's just that no one actually knows when from a given starting number. Say hello to the halting problem). Giving your function a completely meaningless name, such as 'f', does not help. If you have to comment a function to say what does you should just rename your function to something like find_the_next_number(num) and be done with it. Ignoring the comment on the sleep statement for a moment, why the sleep statement at all. Remember that quite a few teachers google the problems they set to see if just this sort of thing is happening :)