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