From: Viera Tarcova Date: 2012-02-07T02:54:17+09:00 Subject: Re: Simple even and odd number loop in Ruby Thank you Bartosz, this is exactly what I was looking for. My loop was not good at all. I am still learning. If you are interested in doing online mentoring, please let me know. I would love to have such a good mentor like you. Bartosz DziewoƄski wrote in post #1044167: > I hope this is not homework. For example this would work: > > 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 > end > end > > num = gets.to_i # read in a number > while true # infinitely... > num = f(num) # find the next number > puts num # print it > sleep 1 # wait one second > end > > Is there anything you don't understand about this code? > > -- Matma Rex -- Posted via http://www.ruby-forum.com/.