Instead of:

  num = gets.chomp

you can directly do:

  num = gets.chomp.to_i
-- 
Posted via http://www.ruby-forum.com/.