This API takes a positive integer between 1 and 3999 (both included) as its parameter and returns a string containing the Roman Numeral representation of that integer.
Modern Roman numerals are written by expressing each digit separately starting with the leftmost digit and skipping any digit with a value of zero. There cannot be more than 3 identical symbols in a row.
In Roman numerals:
2022is written as2000=MM,20=XX,2=IIresulting inMMXXII1990is written as1000=M,900=CM,90=XCresulting inMCMXC2008is written as2000=MM,8=VIIIresulting inMMVIII1666uses each Roman symbol in descending orderMDCLXVI3999is written asMMMCMXCIX
Example:
| Input | Output |
|---|---|
| 1 | I |
| 1000 | M |
| 1666 | MDCLXVI |
| Symbol | Value |
|---|---|
| I | 1 |
| V | 5 |
| X | 10 |
| L | 50 |
| C | 100 |
| D | 500 |
| M | 1,000 |
There is also an endpoint that takes a Roman Numeral string and returns its integer value.
Example:
| Input | Output |
|---|---|
| MMXXI | 2021 |
| MMMCMXCIX | 3999 |
In the root of the directory, run docker compose up. This will pull the build from Docker Hub and run it locally in your Docker environment.
The command exposes port 8080 and shows Swagger UI at http://localhost:8080/swagger/index.html where you can call the API.
Alternatively, you can run the project locally and use Swagger UI, or the supplied Rumerals.Api.http file to call the API (the default port for this file matches when you run the project with the http profile).
There is a test suite that tests the conversion of valid and invalid conversions to Roman Numerals, and valid conversions from Roman Numerals.