Problem
Roman Numerals
Roman numerals aren’t used much in modern computing, and they’re tricky to understand. Interestingly, they don’t include a zero, or do they?
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
| |
Rules
- Typically, Roman numerals are written from largest to smallest, left to right.
- Repeating a numeral up to three times indicates addition, such as III for 3 (1 + 1 + 1).
- Only
I,X,C, andMcan be repeated;V,L, andDcannot. - Numerals in decreasing order from left to right are additive: LX for 60 (50 + 10), XVI for 16 (10 + 5 + 1).
- To avoid repeating a numeral four or more times, smaller numerals placed before larger ones indicate subtraction, like IV for 4 (5 - 1) or IX for 9 (10 - 1). Only specific numeral pairs use this rule.
Examples
For instance, 2 is written as II, combining two ones. 12 is XII, and 27 is XXVII.
The numeral for four is not IIII, but IV, indicating subtraction. Similarly, nine is written as IX. Specific subtraction rules are:
IbeforeV(5) andX(10) makes 4 and 9.XbeforeL(50) andC(100) makes 40 and 90.CbeforeD(500) andM(1000) makes 400 and 900.
Some more examples:
| Roman | Hindu Equivalent Value |
|---|---|
| IV | 4 = 5 - 1 |
| IX | 9 = 10 - 1 |
| XL | 40 = 50 - 10 |
| XC | 90 = 100 - 10 |
| CD | 400 = 500 - 100 |
| CM | 900 = 1000 - 100 |
Full List
Here is the list:
| Number | Roman numeral |
| 0 | not defined |
| 1 | I |
| 2 | II |
| 3 | III |
| 4 | IV |
| 5 | V |
| 6 | VI |
| 7 | VII |
| 8 | VIII |
| 9 | IX |
| 10 | X |
| 11 | XI |
| 12 | XII |
| 13 | XIII |
| 14 | XIV |
| 15 | XV |
| 16 | XVI |
| 17 | XVII |
| 18 | XVIII |
| 19 | XIX |
| 20 | XX |
| 30 | XXX |
| 40 | XL |
| 50 | L |
| 60 | LX |
| 70 | LXX |
| 80 | LXXX |
| 90 | XC |
| 100 | C |
| 200 | CC |
| 300 | CCC |
| 400 | CD |
| 500 | D |
| 600 | DC |
| 700 | DCC |
| 800 | DCCC |
| 900 | CM |
| 1000 | M |
| 5000 | V |
| 10000 | X |
| 50000 | L |
| 100000 | C |
| 500000 | D |
| 1000000 | M |