[Question]
  [
Given a strictly positive integer, return the shortest possible Roman numeral using only the additive rule. Output must consist of zero or more of each of the characters `MDCLXVI` in that order. The number `14` must therefore give `XIIII` rather than `XIV`.
The characters' numeric values are `M`=1000, `D`=500, `C`=100, `L`=50, `X`=10, `V`=5, `I`=1.
### Examples
`3` → `III`
`4` → `IIII`
`9` → `VIIII`
`42` → `XXXXII`
`796` → `DCCLXXXXVI`
`2017` → `MMXVII`
`16807` → `MMMMMMMMMMMMMMMMDCCCVII`
  
[Answer]
# [Plain English](https://github.com/Folds/english), ~~1059~~ ~~1025~~ ~~678~~ ~~641~~ ~~451~~ 399 bytes
Saved 34 bytes by removing an error trap. Then saved 384 bytes by golfing. Then saved 190 bytes by combining the division operation with the append operation ("z") into a new operation ("p"). Then saved 52 bytes by golfing.
```
A s is a string.
To p a r remainder a s a x string a n number:
If the x is "", exit.
Divide the r by the n giving a q quotient and the r.
Fill a t s with the x's first's target given the q.
Append the t to the s.
To convert a r number to a s:
p the r the s "M" 1000.
p the r the s "D" 500.
p the r the s "C" 100.
p the r the s "L" 50.
p the r the s "X" 10.
p the r the s "V" 5.
p the r the s "I" 1.
```
Here is the ungolfed version of the final code, plus an error trap for a negative number:
```
A roman numeral is a string.
To process a remainder given a roman numeral and a letter string is a number:
  If the letter is "", exit.
  Divide the remainder by the number giving a quotient and the remainder.
  Fill a temp string with the letter's first's target given the quotient.
  Append the temp string to the roman numeral.
To convert a number to a roman numeral:
  If the number is negative, exit.
  Put the number in a remainder.
  Process the remainder given the roman numeral and "M" is 1000.
  Process the remainder given the roman numeral and "D" is  500.
  Process the remainder given the roman numeral and "C" is  100.
  Process the remainder given the roman numeral and "L" is   50.
  Process the remainder given the roman numeral and "X" is   10.
  Process the remainder given the roman numeral and "V" is    5.
  Process the remainder given the roman numeral and "I" is    1.
```
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), ~~25~~ 22 bytes
```
'MDCLXVI'/⍨(0,6⍴2 5)∘⊤
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v8/7VHbBHVfF2efiDBPdf1HvSs0DHTMHvVuMVIw1XzUMeNR1xKuR31TgYrSgBSZzP//jblMuEyMuMwtzbiMDAzNuQzNLAzMAQ "APL (Dyalog Classic) – Try It Online")
[Answer]
# [Retina](https://github.com/m-ender/retina), ~~57~~ 42 bytes
Converts to unary, then greedily replaces bunches of `I`s with the higher denominations in order.
```
.*
$*I
I{5}
V
VV
X
X{5}
L
LL
C
C{5}
D
DD
M
```
[**Try it online**](https://tio.run/##K0otycxL/K@q4Z7wX0@LS0XLk8uz2rSWK4wrLIwrgisCxPbh8vHhcuZyBrFduFxcuHz/ayZwccUkcP035jLhMjHiMrc04zIyMDTnMjSzMDAHAA)
*Saved 15 bytes thanks to Martin*
[Answer]
# [Python 2](https://docs.python.org/2/), 64 bytes
```
f=lambda n,d=5,r='IVXLCD':r and f(n/d,7-d,r[1:])+n%d*r[0]or'M'*n
```
[Try it online!](https://tio.run/##BcGxCsIwEADQ3a@4RdLWKyaxNhqIiy6CriKUDJEQDOilHF38@vje/FvehXStyX3C9xUDEEa3R3bi@njezhdhGQJFSA1tI5o@Ik/K@nZD69jxJH1hcRcd1VQYMmSCaYcDDhrNcUQtlUE1HqTxdgUzZ1ogo@hPAlOT2/oH "Python 2 – Try It Online")
Rather than creating the output string from the start by greedily taking the largest part, this creates it from the end. For instance, the number of `I`'s is `n%5`, then the number of `V`'s is `n/5%2`, and so on. This is mixed base conversion with successive ratios of 5 and 2 alternating. 
Here's an iterative equivalent:
**[Python 2](https://docs.python.org/2/), 68 bytes**
```
n=input();s='';d=5
for c in'IVXLCD':s=n%d*c+s;n/=d;d^=7
print'M'*n+s
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P882M6@gtERD07rYVl3dOsXWlCstv0ghWSEzT90zLMLH2UXdqtg2TzVFK1m72DpP3zbFOiXO1pyroCgzr0TdV10rT7v4/39DMwsDcwA "Python 2 – Try It Online")
The `M`'s need to be handled separately because any number of them could be present as there's no larger digit. So, after the other place values have been assigned, the value remaining is converted to `M`'s.
For comparison, a greedy strategy (69 bytes):
**[Python 2](https://docs.python.org/2/), 69 bytes**
```
f=lambda n,d=1000,r='MDCLXVI':r and n/d*r[0]+f(n%d,d/(d%3*3-1),r[1:])
```
[Try it online!](https://tio.run/##BcG9CsIwEADg3ae4paSpV5qf0mohLroIuooQOkSOYECvJXTx6eP3rb/tvbApJbpP@L4oACM5rZTC7MT9cr49H1cxZQhMwB012at5H2uuCKmrqbKNbbXE7PU0yxKXDAkSg7fYY29wPA5olB5RDwc1ztMO1px4g4SiPQmMdZLlDw "Python 2 – Try It Online")
The current digit value `d` is divided by either 2 or 5 to produce the next digit. The value of `d%3` tell us which one: if `d%3==1`, divide by `2`; and if `d%3==2`, divide by 5.
[Answer]
## Mathematica, 81 bytes
```
Table@@@Thread@{r=Characters@"MDCLXVI",#~NumberDecompose~FromRomanNumeral@r}<>""&
```
Explicitly using the values and deriving the corresponding numerals seems to be one byte longer:
```
Table@@@Thread@{RomanNumeral[n={1000,500,100,50,10,5,1}],#~NumberDecompose~n}<>""&
```
[Answer]
# Excel, ~~236~~ ~~193~~ 161 bytes
~~43 bytes saved thanks to @[BradC](https://codegolf.stackexchange.com/users/70172/bradc)~~
At this point, the answer really belongs totally to @[BradC](https://codegolf.stackexchange.com/users/70172/bradc). Another 32 bytes saved.
```
=REPT("M",A1/1E3)&REPT("D",MOD(A1,1E3)/500)&REPT("C",MOD(A1,500)/100)&REPT("L",MOD(A1,100)/50)&REPT("X",MOD(A1,50)/10)&REPT("V",MOD(A1,10)/5)&REPT("I",MOD(A1,5))
```
Formatted:
```
=REPT("M",A1/1E3)
    &REPT("D",MOD(A1,1E3)/500)
    &REPT("C",MOD(A1,500)/100)
    &REPT("L",MOD(A1,100)/50)
    &REPT("X",MOD(A1,50)/10)
    &REPT("V",MOD(A1,10)/5)
    &REPT("I",MOD(A1,5))
```
[Answer]
# [Perl 5](https://www.perl.org/), 66 bytes
65 bytes of code + `-p` flag.
```
$s=1e3;for$@(MDCLXVI=~/./g){$\.=$@x($_/$s);$_%=$s;$s/=--$|?2:5}}{
```
[Try it online!](https://tio.run/##K0gtyjH9r6xYAKQVdAv@qxTbGqYaW6flF6k4aPi6OPtEhHna1unr6adrVqvE6NmqOFRoqMTrqxRrWqvEq9qqFFurFOvb6uqq1NgbWZnW1lb//29uaQYA "Perl 5 – Try It Online")
Without changing the byte count, `MDCLXVI=~/./g` can be replaced by `M,D,C,L,X,V,I`; and `--$|?2:5` by `$|--*3+2`.
Much longer ([99 bytes](https://tio.run/##K0gtyjH9r6xYAKQVdAv@q8Tb@ipUaKjE6xumGmvquYDZqkC2vqmBgaaeM4QPZOsbgvg@UHkg3xTIjYBJA2U19cJgkvqmmnqeUCnN/9YKKvEKerYKSjF5Sv@NuUy4TIy4LM24jAwMzbkMzSwMzAE)), there is:
```
$_=M x($_/1e3).D x($_%1e3/500).C x($_%500/100).L x($_%100/50).X x($_%50/10).V x($_%10/5).I x($_%5)
```
[Answer]
# [CJam](https://sourceforge.net/p/cjam), ~~35~~ 28 bytes
*-7 bytes thanks to Martin Ender*
```
q~{5md\2md\}3*]W%"MDCLXVI".*
```
[Try it online!](https://tio.run/##S85KzP3/v7Cu2jQ3JcYIiGuNtWLDVZV8XZx9IsI8lfS0/v83MjA0BwA "CJam – Try It Online")
### Explanation
```
q~         e# Read and eval input (push the input as an integer).
{          e# Open a block:
 5md\      e#  Divmod the top value by 5, and bring the quotient to the top.
 2md\      e#  Divmod that by 2, and bring the quotient to the top.
}3*        e# Run this block 3 times.
]W%        e# Wrap the stack in an array and reverse it. Now we've performed the mixed-base
           e# conversion.
"MDCLXVI"  e# Push this string.
.*         e# Element-wise repetition of each character by the numbers in the other array.
           e# Implicitly join and print.
```
[Answer]
# C#, 127 bytes
```
f=n=>n>999?"M"+f(n-1000):n>499?"D"+f(n-500):n>99?"C"+f(n-100):n>49?"L"+f(n-50):n>9?"X"+f(n-10):n>4?"V"+f(n-5):n>0?"I"+f(n-1):""
```
A purely hard coded ternary statement using recursion.
Full/Formatted version:
```
using System;
class P
{
    static void Main()
    {
        Func<int, string> f = null;
        f = n => n > 999 ? "M" + f(n - 1000)
                         : n > 499 ? "D" + f(n - 500)
                                   : n > 99 ? "C" + f(n - 100)
                                            : n > 49 ? "L" + f(n - 50)
                                                     : n > 9 ? "X" + f(n - 10)
                                                             : n > 4 ? "V" + f(n - 5)
                                                                     : n > 0 ? "I" + f(n - 1)
                                                                             : "";
        Console.WriteLine(f(3));
        Console.WriteLine(f(4));
        Console.WriteLine(f(42));
        Console.WriteLine(f(796));
        Console.WriteLine(f(2017));
        Console.WriteLine(f(16807));
        Console.ReadLine();
    }
}
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~29~~ ~~26~~ 25 bytes
```
¸5n3×Rvćy‰ì}"MDCLXVI"Ss×J
```
[Try it online!](https://tio.run/##AS4A0f8wNWFiMWX//8K4NW4zw5dSdsSHeeKAsMOsfSJNRENMWFZJIlNzw5dK//8yNjc5 "05AB1E – Try It Online")
**Explanation**
```
¸                           # wrap input in a list
 5n                         # push 5**2
   3×                       # repeat it 3 times
     Rv                     # for each digit y in its reverse
       ć                    # extract the head of the list 
                            # (div result of the previous iteration, initially input)
        y‰                  # divmod with y
          ì                 # prepend to the list
           }                # end loop
            "MDCLXVI"S      # push a list of roman numerals
                      s×    # repeat each a number of times corresponding to the result
                            # of the modulus operations
                        J   # join to string
```
[Answer]
# JavaScript (ES6), ~~81~~ ~~75~~ 69 Bytes
Saved 6 bytes thanks to @Neil for porting @Jörg Hülsermann's answer
Saved 6 bytes thanks to @Shaggy
```
n=>'MDCLXVI'.replace(/./g,(c,i)=>c.repeat(n/a,n%=a,a/=i%2?5:‌​2),a=1e3)
```
**Test cases:**
```
f=
n=>'MDCLXVI'.replace(/./g,(c,i)=>c.repeat(n/a,n%=a,a/=i%2?5:‌​2),a=1e3)
const testCases = [3, 4, 42, 796, 2017, 16807]
testCases.forEach(testCase => console.log(f(testCase)))
```
[Answer]
# [///](https://esolangs.org/wiki////), 50 bytes
```
/1/I//IIIII/V//VV/X//XXXXX/L//LL/C//CCCCC/D//DD/M/
```
[Try it online!](https://tio.run/##XcExCsAgEACwJwXfoItg18O1Q6FDN//PiWuT9d3rfVamotMPQYTJPAzGUKmHRmsuWX5yAw "/// – Try It Online")
Takes input in unary, and I'm (ab)using the footer field on TIO for input so output is preceded by a newline.
[Answer]
# [Python 3](https://docs.python.org/3/), ~~100 97 96 94 93 91~~ 90 bytes
* saved 4+2 bytes: use of `def`; array as default parameter reduced an indentation space; unwanted variable declaration removed
* @shooqie saved 1 byte `a%=` shorthand
* saved 2 bytes: rearranged and braces in `(a//i)` got removed
* @Wondercricket saved 1 byte: move the array from default parameter to within the function which removed `[]` at the cost of one indentation space, thus saving 1 byte.
```
def f(a):
 b=1000,500,100,50,10,5,1
 for i in b:print(end=a//i*'MDCLXVI'[b.index(i)]);a%=i
```
[Try it online!](https://tio.run/##K6gsycjPM/7/PyU1TSFNI1HTikshydbQwMBAxxSIDcE0kNIx1THkUkjLL1LIVMjMU0iyKijKzCvRSM1LsU3U18/UUvd1cfaJCPNUj07Sy8xLSa3QyNSM1bROVLXN/J@mYW5ppvkfAA "Python 3 – Try It Online")
[Answer]
# [Cubix](https://github.com/ETHproductions/cubix), 69 ~~74~~ ~~80~~ bytes
```
/.UI,..N&..0\0&/52"IVXLCDM"U,r%ws;rr3tu;pw..u;qrUosv!s.u\psq,!@Us(0;U
```
[Try it online!](https://tio.run/##Sy5Nyqz4/19fL9RTR0/PT01PzyDGQE3f1EjJMyzCx9nFVylUp0i1vNi6qMi4pNS6oFxPr9S6sCg0v7hMsVivNKaguFBH0SG0WMPAOvT/f3NLSwA "Cubix – Try It Online")
```
        / . U I
        , . . N
        & . . 0
        \ 0 & /
5 2 " I V X L C D M " U , r % w
s ; r r 3 t u ; p w . . u ; q r
U o s v ! s . u \ p s q , ! @ U
s ( 0 ; U . . . . . . . . . . .
        . . . .
        . . . .
        . . . .
        . . . .
```
[Watch It Running](https://ethproductions.github.io/cubix/?code=ICAgICAgICAvIC4gVSBJCiAgICAgICAgLCAuIC4gTgogICAgICAgICYgLiAuIDAKICAgICAgICBcIDAgJiAvCjUgMiAiIEkgViBYIEwgQyBEIE0gIiBVICwgciAlIHcKcyA7IHIgciAzIHQgdSA7IHAgdyAuIC4gdSA7IHEgcgpVIG8gcyB2ICEgcyAuIHUgXCBwIHMgcSAsICEgQCBVCnMgKCAwIDsgVSAuIC4gLiAuIC4gLiAuIC4gLiAuIC4KICAgICAgICAuIC4gLiAuCiAgICAgICAgLiAuIC4gLgogICAgICAgIC4gLiAuIC4KICAgICAgICAuIC4gLiAuCg==&input=NzA2Cg==&speed=15)
I have managed to compress it a bit more, but there is still some pesky no-ops, especially on the top face.
* `52"IVXLCDM"U` put the necessary divisors and characters on the stack. The 5 and 2 will be used to reduce the div/mod value and the characters will be discarded after use.
* `UIN0/&0\&,/U` u-turns onto the top face and starts a long tour to get the input and push 1000 onto the stack. An initial divide is done and a u-turn onto the `r` of the next snippet. This was an area I was looking at to make some savings.
* `,r%ws;rr` beginning of the divmod loop. integer divide, rotate the result away mod, then rearrange top of stack to be reduced input, current divisor and divide result.
* `3tus` bring the current character to the top and swap it with the divide result.
* `!vsoUs(0;U` this is the print loop. while the div result is more than 0, swap with character output, swap back, decrement, push a 0 and drop it. On 0 redirect over the pop stack (remove divide result) and around the cube.
* `\u;pwpsq,!@Urq;u` with a bit of redirection, this removes the character from the stack, brings the 5 and 2 to the top, swaps them and pushes one back down. The remaining is used to reduce the divisor. Halt if it reduces to 0, otherwise push the 5 or 2 to the bottom and re-enter the loop.
[Answer]
# Mathematica, 130 bytes
```
(f=#~NumberDecompose~{1000,500,100,50,10,5,1};""<>{Flatten@Table[Table[{"M","D","C","L","X","V","I"}[[i]],f[[i]]],{i,Length@f}]})&
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~109~~ 90 bytes
```
lambda n,r=[1000,500,100,50,10,5,1]:''.join(n%a/b*c for a,b,c in zip([n+1]+r,r,'MDCLXVI'))
```
[Try it online!](https://tio.run/##Hcq9DoIwFIbh3as4iynIp7bIj5LgoouJroYEGQqGeIwW0rDozVdwePMsb/8ZHp0JXZvf3Eu/67smA5uXSkqJeEz9HUEMVWVCrJ4dG8/M9bpeNNR2ljRqNMSGvtx7pQlUFVhYiMvxcC6uJ@H7btp4WsoNIkQh0l2CUKoUKtnKtMpm1Fs2AzHEci/Qeuy7Hw "Python 2 – Try It Online")
[Answer]
# [PHP](https://php.net/), 70 bytes
```
for($r=1e3;$a=&$argn;)$a/$r<1?$r/=++$i%2?2:5:$a-=$r*print MDCLXVI[$i];
```
[Try it online!](https://tio.run/##K8go@G9jX5BRwKWSWJSeZ6tkZGBormT9Py2/SEOlyNYw1dhaJdFWDSxpramSqK9SZGNor1Kkb6utrZKpamRvZGVqpZKoa6tSpFVQlJlXouDr4uwTEeYZrZIZa/3/PwA "PHP – Try It Online")
[Answer]
# T-SQL, 164 bytes
```
SELECT REPLICATE('M',n/1000)+IIF(n%1000>499,'D','')
      +REPLICATE('C',n%500/100)+IIF(n%100>49,'L','')
      +REPLICATE('X',n%50/10)+IIF(n%10>4,'V','')
      +REPLICATE('I',n%5)
FROM t
```
Line breaks added for readability only.
This version is a lot longer (230 characters), but feels much more "SQL-like":
```
DECLARE @ INT,@r varchar(99)=''SELECT @=n FROM t
SELECT'I's,1v INTO m
INSERT m VALUES('V',5),('X',10),('L',50),('C',100),('D',500),('M',1000)
L:
    SELECT @-=v,@r+=s 
    FROM m WHERE v=(SELECT MAX(v)FROM m WHERE v<=@)
IF @>0GOTO L
SELECT @r
```
Makes a table *m* with all the char-value mappings, and then loops through finding the largest value <= the number, concatenating the matching character.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 34 bytes
```
"IVXLCD"£%(U/=Y=v *3+2Y)îXÃw i'MpU
```
[Test it online!](http://ethproductions.github.io/japt/?v=1.4.5&code=IklWWExDRCKjJShVLz1ZPXYgKjMrMlkp7ljDdyBpJ01wVQ==&input=MTk5OQ==)
```
"IVXLCD"£    %(U/=Y=v  *3+2Y )îXÃ w i'MpU
"IVXLCD"mXY{U%(U/=Y=Yv *3+2,Y)îX} w i'MpU : Ungolfed
                                          : Implicit: U = input number
"IVXLCD"mXY{                    }         : Map each char X and its index Y in this string to:
                  Y=Yv *3+2               :   Set Y to 5 for even indexes, 2 for odd.
               U/=                        :   Divide U by this amount.
            U%(            ,Y)            :   Modulate the old value of U by 5.
                              îX          :   Repeat the character that many times.
                                          : This returns e.g. "IIVCCCD" for 16807.
                                  w       : Reverse the entire string.
                                    i'MpU : Prepend U copies of 'M' (remember U is now the input / 1000).
                                          : Implicit: output result of last expression
```
[Answer]
## JavaScript (ES6), 65 bytes
A recursive function.
```
f=(n,a=(i=0,1e3))=>n?a>n?f(n,a/=i++&1?5:2):'MDCLXVI'[i]+f(n-a):''
```
### How?
The second recursive call `f(n-a)` really should be `f(n-a,a)`. By omitting the 2nd parameter, `a` and `i` are reinitialized (to 1000 and 0 respectively) each time a new Roman digit is appended to the final result. This causes more recursion than needed but doesn't alter the outcome of the function and saves 2 bytes.
### Test cases
```
f=(n,a=(i=0,1e3))=>n?a>n?f(n,a/=i++&1?5:2):'MDCLXVI'[i]+f(n-a):''
console.log(f(3))
console.log(f(4))
console.log(f(9))
console.log(f(42))
console.log(f(796))
console.log(f(2017))
console.log(f(16807))
```
[Answer]
# [J](http://jsoftware.com/), ~~26~~ 23 bytes
3 bytes saved thanks to Adám.
```
'MDCLXVI'#~(_,6$2 5)&#:
```
[Try it online!](https://tio.run/##y/qvpKegnqZga6WgrqCjYKBgBcS6egrOQTo@bv/VfV2cfSLCPNWV6zTidcxUjBRMNdWUrf5rcpUkg7QYK5goWCqYGCmYW5opGBkYmisYmlkYmHOlJmfkK2hYK6RpKhkolCT/BwA "J – Try It Online")
~~Similar to the APL answer~~ basically the same thing.
```
'MDCLXVI'#~(_,6$2 5)&#:
           (       )&#:   mixed base conversion from decimal
              6$2 5       2 5 2 5 2 5
            _,            infinity 2 5 2 5 2 5
                          this gives us e.g. `0 0 0 0 1 0 4` for input `14`
'MDCLXVI'#~               shape each according to the number of times on the right
                          this is greedy roman numeral base conversion
```
[Answer]
## Batch, 164 bytes
```
@set/pn=
@set s=
@for %%a in (1000.M 500.D 100.C 50.L 10.X 5.V 1.I)do @call:c %%~na %%~xa
@echo %s:.=%
@exit/b
:c
@if %n% geq %1 set s=%s%%2&set/an-=%1&goto c
```
Takes input on STDIN.
[Answer]
# Oracle SQL, 456 bytes
```
select listagg((select listagg(l)within group(order by 1)from dual start with trunc((n-nvl(n-mod(n,p),0))/v)>0 connect by level<=trunc((n-nvl(n-mod(n,p),0))/v)))within group(order by v desc)from (select 2849n from dual)cross join(select 1000v,null p,'m'l from dual union select 500,1000,'d'from dual union select 100,500,'c'from dual union select 50,100,'l'from dual union select 10,50,'x'from dual union select 5,10,'v'from dual union select 1,5,'i'from dual)
```
Outputs:
```
mmdcccxxxxviiii
```
Please note the actual size of the line is 460bytes, because it includes the input number (2849).
Ungolfed:
```
select listagg(
            (select listagg(l, '') within group(order by 1) 
             from dual 
             start with trunc((n-nvl(p*trunc(n/p),0))/v) > 0 
             connect by level <= trunc((n-nvl(p*trunc(n/p),0))/v) )
        ) within group(order by v desc)
from (select 2348 n
    from dual
) cross join (
    select 1000v, null p, 'm' l from dual union 
    select 500, 1000, 'd' from dual union
    select 100, 500, 'c' from dual union
    select 50, 100, 'l' from dual union
    select 10, 50, 'x' from dual union
    select 5, 10, 'v' from dual union
    select 1, 5, 'i' from dual     
)
```
How it works: 
I calculate how many of each letter I need, by calculating the most I can get to with the higher value one (infinity for M), and then doing an integer division between the current letter's value and the result of that.
E.g. 2348, how many `C`s do I need? `trunc((2348-mod(2348,500))/100)` = 3.
Then, I `listagg` that letter together 3 times (exploiting `CONNECT BY` to generate the 3 rows I need).
Finally, I `listagg` everything together.
Kinda bulky, but most of it is the `select from dual`s in the conversion table and I can't really do much about that...
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), ~~119~~ 118 bytes
```
n->{String s="";for(int v[]={1,5,10,50,100,500,1000},i=7;i-->0;)for(;n>=v[i];n-=v[i])s+="IVXLCDM".charAt(i);return s;}
```
[Try it online!](https://tio.run/##LU9Na4NAEL3nVwyCoHRd1jSJTbYKpaUQaE6BUhAPW6PppmYUd7UE8bfbVXOYeY838@bjIlrhlVWGl9PvUDXfhUwhLYRScBASuwXAXVRaaANtKU9wNSXnqGuJ5zgBUZ@VO3YCXMw02mhZ0LzBVMsS6R71@50/z5YIcghhQC/qZgFUaFk8L2tHooY2TsLOJ2viM7JmJo8wIeuJDAMuPS9i3B37OUZhG8uEozehqx5Ca//59fH6drBo@iPqF@1Il9eZbmoExfuBT4caM0zbcAeY/YGhcdI9khXZktWSBNsNWTI/IP7miQW9C/N7AMeb0tmVlo2mlTld545l@@y0A1vZaBFAAjkVVVXcHHTdeVe/GKNfDP8 "Java (OpenJDK 8) – Try It Online")
Saved a byte thanks to @TheLethalCoder
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 61 50 46 bytes
```
ＮνＡ⁰χＷφ«Ｗ¬‹νφ«§MDCLXVIχＡ⁻νφν»Ａ⁺¹χχＡ÷φ⎇﹪χ²¦²¦⁵φ
```
[Try it online!](https://tio.run/##S85ILErOT8z5///9nnXn9r7fs/BR44bz7e/3bD/fdmg1kDq05lHDznN7QbxDy31dnH0iwjxB8kB1u0HC5/Ye2g3m7Tq083w7WOYwUO@jvvb3O1edbz@06dAyEH7UuPV82///ZhYG5gA "Charcoal – Try It Online")
Explanation:
```
Ｎν                   Take input as number and assign it to ν
Ａ⁰χ                  Let χ=0
Ｗφ«                  While φ>0 (φ has a predefined value of 1000)
    Ｗ¬‹νφ«               While v>=φ 
        §MDCLXVIχ             Take the char from string "MDCLXVI" at position χ
        Ａ⁻νφν»               Let ν=ν-φ
    Ａ⁺¹χχ                Increment χ
    Ａ÷φ⎇﹪χ²¦²¦⁵φ        If χ is odd, divide φ by 5, else divide φ by 2
```
* 4 bytes saved thanks to Neil, while I am still trying to figure out how to proceed with the second part of his comment.
[Answer]
# C++, 272 Bytes
```
#include <cstdio>
#include <map>
std::map<int,char> m = {{1000,'M'},{500,'D'},{100,'C'},{50,'L'},{10,'X'},{5,'V'},{1,'I'}};
int main(){unsigned long x;scanf("%d",&x);for(auto i=m.rbegin();i!=m.rend();++i)while(x>=i->first){printf("%c", i->second);x=x-i->first;}return 0;}
```
[Answer]
# C, 183 Bytes
```
#include <stdio.h>
int v[]={1000,500,100,50,10,5,1};
char*c="MDCLXVI";
int main(){int x;scanf("%d",&x);for(int i=0;i<sizeof v/sizeof(int);i++)for(;x>=v[i];x-=v[i])putc(c[i],stdout);}
```
Same algorithm as before, just using plain c arrays instead of an std::map, partially inspired by @xnor's answer and using a string to store the letters. 
[Answer]
## Common Lisp, 113 bytes
This is an anonymous function, returning the result as a string.
```
(lambda(value)(setf(values a b)(floor v 1000))(concatenate 'string(format()"~v,,,v<~>"a #\M)(format nil"~@:r"b)))
```
Ungolfed, with descriptive variable names and comments:
```
(defun format-roman (value)
  ;; Get "value integer-divided by 1000" and "value mod 1000"
  (setf (values n_thousands remainder) (floor value 1000))
  (concatenate 'string
               ;; Pad the empty string n_thousands times, using "M" as the 
               ;; padding character
               (format () "~v,,,v<~>" n_thousands #\M)
               ;; Format the remainder using "old-style" Roman numerals, i.e. 
               ;; numerals with "IIII" instead of "IV"
               (format nil "~@:r" remainder)))
```
CL has built-in Roman numeral formatter. Sadly it doesn't work for numbers larger than 3999.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 34 bytes
```
ＮςＡ²ξＦMDCLXVI«×ι÷ςφＡ﹪ςφςＡ÷φξφＡ÷χξξ
```
Originally based on @CarlosAlego's answer. A port of @xnor's Python solution is also 34 bytes:
```
ＮθＡ⁵ξＦIVXLCD«←×ι﹪θξＡ÷θξθＡ÷χξξ»←×Mθ
```
Edit: A port of @xnor's other Python solution turns out to be 33 bytes!
```
ＮθＦMDCLXVI«×ι÷θφＡ﹪θφθＡ÷φ⁺×³﹪φ³±¹φ
```
[Try it online!](https://tio.run/##TYy9CsIwGEXn9ik@OiWQglJQwUnsErClg4hrbZMaSBObny7is8eIBR3vuZzT3VvT6VaGQNXDu9qPN2bQhPcp1wZQVpXH0/VCMwzPNGmMUA6dxcgsEgSocqWYRc/QRIBjHKXkYK0YFKp076X@cgLT3/OTOIFGerv0CgKLFHmBo1WzoXUMrfFn8Jh4hbDZrbYhn0Nu5Rs "Charcoal – Try It Online") Link is to verbose version of code. Note that I've used `⁺×³﹪φ³±¹` instead of `⁻×³﹪φ³¦¹` because the deverbosifier is currently failing to insert the separator.
]