These are the production rules for
Roman numerals.
Use these to count with Roman numerals.
(For information on production rules,
see Hofstadter's book,
Gödel,
Escher, Bach: An Eternal Golden Braid.)
(For a Roman-numeral to integer converter, see this
on-line
conversion page.)
When there are multiple rules that could be used, use the one with the lowest
number.
This is a draft; it may be incomplete.
0: | if the string ends in VIII (8), change it to IX (9). |
1: | if we have III (3), it becomes IV (4). |
2: | if we have XXXIX (39) or LXXXIX (89), make it XL (40) or XC (90), respectively. |
3: | if we have XCIX (99) make it C (100). Also handle XLIX, DCCCXCIX and CCCXCIX. |
4: | if an I is followed by V or X, remove that I (aIb -> ab). |
5: | if all else fails, append I. |