Your task is to convert a given positive integer from Arabic numeral to Roman numeral.
Things get difficult when you count to 4000.
The romans did this by adding a line above a symbol to multiply that symbol by 1 000
. However, overlines aren't exactly displayable in ASCII. Also, there are double overlines to multiply a symbol by 1 000 000
, and then triple overline to multiply a symbol by 1 000 000 000
, etc...
Therefore, I decided to use parentheses to replace overlines.
The symbols can be individually placed in parentheses. For example, both (VI)
and (V)(I)
are valid representations of 6 000
. (V)M
is also a valid representation of 6000.
(I)
is a valid way to represent 1 000
.
Testcases
Input: 1
Output: I
Input: 2
Output: II
Input: 3
Output: III
Input: 4
Output: IV
Input: 15
Output: XV
Input: 40
Output: XL
Input: 60
Output: LX
Input: 67
Output: LXVII
Input: 400
Output: CD
Input: 666
Output: DCLXVI
Input: 3000
Output: MMM
Input: 3999
Output: MMMCMXCIX
Input: 4000
Output: M(V)
Input: 4999
Output: M(V)CMXCIX
Input: 6000
Output: (VI)
Input: 6000000
Output: ((VI))
Input: 6006000
Output: ((VI)VI)
Input: 6666666666
Output: (((VI)DCLXVI)DCLXVI)DCLXVI
Scoring
This is code-golf. Shortest code in bytes win.
(IV)
an acceptable representation of 4000? \$\endgroup\$