Search across blog, articles, projects, courses, and community posts
Roman numerals use the symbols I=1, V=5, X=10, L=50, C=100, D=500, M=1000. A symbol is normally added, but when a smaller symbol comes before a larger one it is subtracted (IV = 4, IX = 9, XL = 40, XC = 90, CD = 400, CM = 900). Read a valid Roman numeral and print its value.
Input: one Roman numeral.
Output: its integer value.
The numeral is valid and represents a value from 1 to 3999.
III
3
MCMXCIV
1994