num = gets p num.reverse.gsub( /(\d{3})(?=\d)/, '\1,').reverse.to_i