Example 35: Integer to Roman Conversion

Learn how to convert a year into its roman equivalent form.

Problem

Write a general-purpose function to convert any given year into its roman equivalent. Use the following table to convert a year to its roman equivalent.

Number Roman Equivalent
1 I
5 V
10 X
50 L
100 C
500 D
1000 M

Example

Input Output
1988 mdcccclxxxviii
1525 mdxxv

Try it yourself

Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.