Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Roman Numerals by sebastian009
def checkio(data):
result = ""
while data >= 1000:
result = result + "M"
data = data - 1000
while data >= 900:
result = result + "CM"
data = data - 900
while data >= 500:
result = result + "D"
data = data - 500
while data >= 400:
result = result + "CD"
data = data - 400
while data >= 100:
result = result + "C"
data = data - 100
while data >= 90:
result = result + "XC"
data = data - 90
while data >= 50:
result = result + "L"
data = data - 50
while data >= 40:
result = result + "XL"
data = data - 40
while data >= 10:
result = result + "X"
data = data - 10
if data == 9:
result = result + "IX"
data = data - 9
while data >= 5:
result = result + "V"
data = data -5
if data == 4:
result = result + "IV"
data = data - 4
while data >= 1:
result = result + "I"
data = data - 1
return result
Oct. 16, 2016