Roman numbers (1)

Write a program that reads several numbers and prints their equivalent
Roman number.

Remember that Roman numbers make use seven uppercase letters, which
correspond to the following values:

   Letter   I   V   X    L     C     D     M
  -------- --- --- ---- ---- ----- ----- ------
   Value    1   5   10   50   100   500   1000

These are the rules of Roman numbers:

- Each decimal digit is computed independently.

- Units (1, 2, …, 9) are represented, respectively, I, II, III, IV, V,
  VI, VII, VIII, IX. Nothing is written for 0.

- Tens (10, 20, …, 90) are written like units are, but repacing I by X,
  V by L, and X by C.

- Hundreds (100, 200, …, 900) are written like units are, but repacing I
  by C, V by D, and X by M.

- Thousands (1000, 2000 i 3000) are written like units are, but repacing
  I by M.

Input

Input consists of several natural numbers between 1 and 3999. (Roman
people did not know zero, and the system described above cannot
represent numbers greater than or equal to 4000.)

Output

For each number, print its equivalent Roman number.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:20:28.223Z

© Jutge.org, 2006–2026.
https://jutge.org
