Roman Numerals

What are the characters used to represent numbers in roman numerals?

I, V, X, L, C, D, M

Values of the characters.

I - 1

V - 5

X - 10

L - 50

C - 100

D - 500

M - 1000

A letter can repeat up to 3 times. Not more than 3 times. When a letter repeats then the values will be added.

Example:

III = 3 (1 + 1+ 1)

MMM = 3000 (1000 + 1000 + 1000)

IIII - illegal

CCCC - illegal

If one or more letters placed after another letter with higher values then add the values to the base amount.

Example:

XVII = 10 (X) + 5 (V) + 1 (I) + 1 (I) = 17

If a letter placed before another letter with higher values then subtract the value from the base amount. More than one value can't be placed for subtraction.

Example:

XC= 100 (C) - 10 (X) = 90

If one or more letters placed after another letter with higher values and also a letter placed before the letter with the higher value, First perform subtraction and then continue with addition.

Example:

XCVI = 100 ( C ) - 10 (X) + 5 (V) + 1 (I) = 96

It is not allowed to subtract a value from a bigger value if the smaller value is more than 10 times smaller.

Example:

IC = (100 - 1) illegal because I is 100 times smaller.

IC should be represented as XCIX (100 - 10 + 10 -1 = 99)

Only a power of 10 can be subtracted from a higher value.

Example:

CM = (1000 - 100 ) = 900

DM = (1000 - 500 ) is illegal because 500 (D) is not a power of 1000.

More than one value can't be subtracted from a higher value.

Example

IVX = (10 - 5 - 1) = illegal

A bar placed on top of a letter increases the value by 1,000 times.

Example:

IV = 4

=4000

LI=4051