```Viera Tarcova wrote in post #1044163:
> Hello guys, I am trying to develop a simple loop in Ruby. You need to
> type in a number. When this number is an "even" number, it will divide
> it by 2. If it is an odd number, it will multiply it by 3. This goes in
> a loop... so for instance if you type in number "20", Ruby would write
> an answer like this: 20, 10, 5, 15, 45,... infinitelly...always either
> dividing or multiplying the number that it gets depending on whether it
> is an odd or even number.
>
> I tried so many things these days, but none of them were working.

This should provide some clarity with the following two examples:

If you wanted to print out only even integers from 0 - 20

i = 20
loop do
i -= 1
next if i % 2 != 0
print "#{i}"
break if i <= 0
end

(note technically it will only return even values up to 18, but you can
adjust the i = value as necessary)

If you wanted to print out only odd integers from 0 -20

i = 20
loop do
i -= 1
next if i % 2 == 0
print "#{i}"
break if i <= 0
end

(note technically it will only return odd values from 1 - 19)

--
Posted via http://www.ruby-forum.com/.
```