I = 1, V = 5, X = 10, L = 50, C = 100, D = 500 and M = 1000.
A number is written place by place, from the highest decimal place down, and each place is encoded on its own:
- digits 1–3 repeat the place's unit symbol (I, X, C or M): 3 = III, 30 = XXX;
- digits 5–8 use the place's "five" symbol (V, L, D) followed by unit symbols: 7 = VII, 60 = LX;
- digits 4 and 9 are written by subtraction, with the unit symbol placed before the "five" or the "ten" of the same place: 4 = IV, 9 = IX, 40 = XL, 90 = XC, 400 = CD, 900 = CM.
Given an integer number, return it in Roman numerals.number=2468 → 'MMCDLXVIII'
2000 = MM, 400 = CD, 60 = LX, 8 = VIII.
number=94 → 'XCIV'
90 = XC, 4 = IV. IC is not allowed: subtraction only works within one decimal place.
number=7 → 'VII'
5 + 1 + 1 = VII.
number ≤ 3999number=2468
'MMCDLXVIII'
Run checks the first 3 tests in your browser. Submit checks all 80 tests on the server, hidden ones included.