The first thing to know is the value of the Roman digit. These are given below.
1=I
5=V
10=X
50=L
100=C
500=D
1000=M
Now the only thing to write Roman numbers are the logic required.
Right side of bigger digit of Roman system is added, and the left digit is subtracted.