your next if should work for the odds number..
for even number it will be
next if i % 2 == 0
if the remains of the division by 2 is equal to 0
so for odds number do see how you can do it?
change the puts with print