def check_column(i)
case i
when 1000
r = 'M'
s = ''
when 100
r = 'C'
s = 'D'
when 10
r = 'X'
s = 'L'
else
r = 'I'
s = 'V'
end
return r,s
end
def check_roman(i,q)
check = q.to_f / 4
if check < 1
r,s = check_column(i)
r_num = r * q
elsif check == 1
r,s = check_column(i)
r_num = r + s
elsif check <= 2
r,s = check_column(i)
r_num = s + r * (q - 5)
elsif check > 2
r,s = check_column(i)
r_n,s_n = check_column(i * 10)
r_num = r + r_n
end
return r_num
end
num = ARGV[0].to_i
r_num = ''
if num / 3000 > 1
p " there aree not roman numerals over 3000"
else
[1000,100,10,1].each do |i|
q = num / i
if q != 0
r_num += check_roman(i,q)
p r_num
end
num = num - q * i
end
end