Roman numerals
We use this kata to develop the concepts of Transformation Priority Premise
Last updated
We use this kata to develop the concepts of Transformation Priority Premise
Last updated
Roman numerals is a numbering system which uses Latin alpha characters to represent a known set of numbers and combinations of these to represent all others.
Write a function which can take any integer from 1-1000 and return its Roman numeral representation as a string.
Combine Roman numerals to make bigger numbers, e.g. I = 1, II = 2 (1 + 1), VI = 6 (5 + 1). Larger numerals come before (left of) smaller ones.
You cannot combine more than three of the same numeral, e.g. IIII = 4 is not valid. Instead, you must use the next numeral up and prefix it with a numeral to subtract from it, e.g. IV = 4 (1 less than 5), XL = 40 (10 less than 50). You can spot these exceptional cases because the smaller numeral comes before (left of) the larger.
Arabic number
Roman numeral
Arabic number
Roman numeral
1
I
5
V
10
X
50
L
100
C
500
D
1000
M
Arabic
number
Roman
numeral
Arabic
number
Roman
numeral
Arabic
number
Roman
numeral
2
II
20
XX
200
CC
3
III
30
XXX
300
CCC
4
IV
40
XL
400
CD
6
VI
60
LX
600
DC
7
VII
70
LXX
700
DCC
8
VIII
80
LXXX
800
DCCC
9
IX
90
XC
900
CM
Arabic number
Roman numeral
Hundreds
Tens
Units
42
XLII
-
XL
II
584
DLXXXIV
D
LXXX
IV
777
DCCLXXVIII
DCC
LXX
VII
999
CMXCIX
CM
XC
IX