From: Faith Tarcha Date: 2012-02-08T20:20:49+09:00 Subject: Count the numbers in a loop Hello everyone, I have this code. You type in a number and then it identifies odd and even numbers. When it identifies an odd number, it will multiply it by three plus one. When It identifies an even number, it will divide it by 2. This will go infinitely until it reaches number 1, then the loop will stop. Does anyone know how to make it count all the numbers that appear on the screen (until the loop stops at number 1)? I have tried everything in the last 2 days.. but so far not being successful. Thank you This is the code: def f n # this function calculates next number in your sequence if n % 2 == 0 # n is even return n / 2 else return n * 3+1 end end num = gets.to_i # read in a number while num > 1 # infinitely... num = f(num) # find the next number puts num # print it sleep 1 # wait one second end -- Posted via http://www.ruby-forum.com/.