Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Use the table solution in Clear category for Roman Numerals by ludek.reif
def checkio(number):
table = {1: 'I', 4: 'IV', 5: 'V', 9: 'IX', 10: 'X', 40: 'XL', 50: 'L',
90: 'XC', 100: 'C', 400: 'CD', 500: 'D', 900: 'CM', 1000: 'M'}
roman = ''
for i in sorted(table, reverse=True):
if number < i:
continue
roman += (number//i)*table[i]
number -= (number//i)*i
return roman
Sept. 18, 2019