Converts a given integer into a Roman numeral.
integerRoman = {1000: "M", 900: "CM", 500: "D", 400: "CD", 100: "C", 90: "XC", \
50: "L", 40: "XL", 10: "X", 9: "IX", 5: "V", 4: "IV", 1: "I"}
def integer_to_roman(data):
"""
Input: A number as an integer.
Output: The Roman numeral as a string.
Precondition: 0 < number < 4000
"""
steps = integerRoman.keys()
steps.sort()
steps.reverse()
return int_to_roman(data, steps)
def int_to_roman(num, steps):
if num == 0:
return ""
return (num / steps[0]) * integerRoman[steps[0]] + int_to_roman(num % steps[0], steps[1:])