...

/

Roman Numerals to Integers

Roman Numerals to Integers

Given a Roman numeral, convert it to an integer.

Statement

Given a Roman numeral, our task is to convert it to an integer.

Roman numerals are represented by seven different symbols:

“I”, “V”, “X”, “L”, “C”, “D”, and “M”.

Symbol

Value

I

1

V

5

X

10

L

50

C

100

D

500

M

1000

Roman numerals are traditionally written from left to right, from largest to smallest.

  • However, the numeral for four is “IV” instead of “IIII”. We deduct the one because it is less than five, resulting in four.
  • The number nine, written as “IX,” follows the same pattern.

This subtraction rule occurs in six different situations:

  • “I” can be placed before “V” (5) and “X” (10) to make four and nine, respectively.
  • “X” can be placed
...
Access this course and 1400+ top-rated courses and projects.