Skip to content

Commit

Permalink
Create interger_to_roman_num.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh Singhal authored Nov 29, 2020
1 parent e8b89a9 commit b72f0bd
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions interger_to_roman_num.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Write a program to convert interger to Roman Representation
def convertIntegerToRomanNum(inputNumber):

number_list = [
1000, 900, 500, 400,
100, 90, 50, 40,
10, 9, 5, 4,
1
]

symbol_list = [
'M', 'CM', 'D', 'CD',
'C', 'XC', 'L', 'XL',
'X', 'IX', 'V', 'IV',
'I'
]

result_str = ''
i = 0

while inputNumber > 0:
for _ in range(inputNumber//number_list[i]):
result_str = result_str + symbol_list[i]
inputNumber = inputNumber - number_list[i]
i = i + 1
return result_str

roman = convertIntegerToRomanNum(289)
print(roman)

0 comments on commit b72f0bd

Please sign in to comment.