Skip to content

Integer to Roman

MediumBit Manipulation & Math
Decode it first. Clues, constraints, pattern and plan before any code.

Convert an integer num to a Roman numeral. Use the symbols I (1), V (5), X (10), L (50), C (100), D (500), M (1000), and the six subtractive forms IV (4), IX (9), XL (40), XC (90), CD (400), CM (900). A symbol never repeats more than three times in a row.

num = 3     →  "III"
num = 58    →  "LVIII"
num = 1994  →  "MCMXCIV"

Constraints

  • 1 <= num <= 3999