Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pedroka-dev/roman-numerals
🏛 C# app that can convert integers to roman numerals
https://github.com/pedroka-dev/roman-numerals
coding-exercise csharp
Last synced: about 1 month ago
JSON representation
🏛 C# app that can convert integers to roman numerals
- Host: GitHub
- URL: https://github.com/pedroka-dev/roman-numerals
- Owner: pedroka-dev
- License: mit
- Created: 2021-06-10T17:18:29.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-11T19:33:36.000Z (5 months ago)
- Last Synced: 2024-07-12T23:03:38.639Z (4 months ago)
- Topics: coding-exercise, csharp
- Language: C#
- Homepage:
- Size: 1.31 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Roman-Numerals
A app that can convert integers to roman numerals# The Problem
The Roman numeral system developed in Ancient Rome and was used throughout its Empire.
In this system, numbers are written using specific letters, each representing certain values. The letters are always uppercase, as there are no lowercase letters in the Roman alphabet. The letters are I, V, X, L, C, D, and M.
Your task is to develop a program that converts Indo-Arabic numbers to the Roman format and vice versa.
The rules for forming Roman numerals are presented below.
Each letter corresponds to a specific value:
I = 1
V = 5
X = 10
L = 50
C = 100
D = 500
M = 1000
By grouping the above letters, we can represent numbers according to a set of rules:
With the exception of V, L, and D, other numerals can be repeated a maximum of three times:
III = 3
XXX = 30
CCC = 300
MMM = 3000
For numbers from 4000 onwards, the digits are the same as for the units (IV, V, VI, VII, VIII, IX, X), but with a macron (bar) over the digit:
ĪV̄ = 4000
V̄ = 5000
V̄Ī = 6000
V̄ĪĪ = 7000
V̄ĪĪĪ = 8000
ĪX̄ = 9000
X̄ = 10000
When written to the right of larger numerals, I, X, and C are added to the values of the preceding numerals:
VIII = 5 + 1 + 1 + 1 = 8
LXII = 50 + 10 + 1 + 1 = 62
CLVIII = 158
MCXX = 1000 + 100 + 10 + 10 = 1120
But if the numerals I, X, and C are to the left of larger numerals, their values are subtracted, as in:
IV = 5 - 1 = 4
IX = 10 - 1 = 9
XC = 100 - 10 = 90