g | x | w | all
Bytes Lang Time Link
nanScala 3250528T004639ZAhamad
051Bash250527T003132ZDigital
030Uiua 0.17.0dev.1250526T141653ZTbw
073Python 3250527T114723ZJonathan
010APL Dyalog Extended250527T214625ZAdá
080Ruby250526T195503ZLevel Ri
170Python 3.8+250526T155046ZCrSb0001
126Python250526T231247ZLucenapo
015R250527T081002Zpajonk
00505AB1E250527T075342ZKevin Cr
084JavaScript Node.js250527T025308Ztata
095JavaScript V8250526T203406ZArnauld
022Wolfram Language Mathematica250526T135219ZThemooni
018Excel250526T161850Zz..
038Charcoal250526T160122ZNeil
021Vyxal 3250526T143511ZThemooni
007Vyxal250526T134134Zlyxal
081Retina 0.8.2250526T131758ZNeil

Scala 3, 300 277 bytes

- 23 bytes thanks to @CrSb0001

       

Golfed version. Attempt This Online!

object M{def main(a:Array[String]):Unit={import scala.collection.mutable.ArrayBuffer
var r=ArrayBuffer[String]()
for(i<-0 to 1892){var m= -137&i
var n=""
val c="IVXLCD"
for(h<-c){n=h.toString*(m%4)+n
m/=4}
r=r union ArrayBuffer(n)}
println(r.filterNot(_=="").distinct.toList)}}

Ungolfed version. Attempt This Online!

object Main {
  def main(args: Array[String]): Unit = {
    // Initialize an empty buffer to store Roman numerals
    import scala.collection.mutable.ArrayBuffer
    var romanNumerals = ArrayBuffer[String]()
    
    // Iterate 1893 times (covers all possible Roman numeral combinations)
    for (index <- 0 until 1893) {
      // Apply bitwise AND with -137 to the index
      // This creates a specific pattern for Roman numeral generation
      var modifiedIndex = index & -137
      
      // Initialize empty string for building the Roman numeral
      var romanNumeral = ""
      
      // Roman numeral characters in reverse order of value
      // I(1), V(5), X(10), L(50), C(100), D(500)
      val romanChars = "IVXLCD"
      
      // Process each Roman character
      for (character <- romanChars) {
        // Get remainder when dividing by 4, repeat the character that many times
        val repetitions = modifiedIndex % 4
        val repeatedChars = character.toString * repetitions
        
        // Prepend to build Roman numeral from right to left
        romanNumeral = repeatedChars + romanNumeral
        
        // Integer divide by 4 for next iteration
        modifiedIndex = modifiedIndex / 4
      }
      
      // Add the Roman numeral to our collection using union operator
      // (union operator automatically handles duplicates)
      romanNumerals = romanNumerals union ArrayBuffer(romanNumeral)
    }
    
    // Print the array excluding empty strings
    val result = romanNumerals.filterNot(_ == "").distinct
    println(result.toList)
  }
}

Bash, 51

Credit to @TobySpeight, @JonathanAllan, @Mat_rdv for the corrections and additional golfing!

echo {,MM}{,M}{,C,CD,D,DC}{,X,XX,L,LX}X{,I,IV,V,VI}

Try it online!

Uiua 0.17.0-dev.1, 34 30 bytes SBCS

↘12♭⍚₁⌟(/◇⊂⍚↯)⇡↯[6]2_4"DCLXVI"

Try on Uiua Pad!

-3 bytes thanks to @Jonathan Allan

Outputs the numbers 15 through 888 that do not contain 4 or 9 as digit.

This code lists every combination of up to 1 "D"s followed by up to 3 "C", up to 1 "L", and so on. Then we drop the first 12 (of 512).

Python 3,  110 90 82  73 bytes

-9 thanks to Albert.Lang!

for i in range(500):
 m=2
 for c in"DCLXVI ":print(end=~i%m*c);i//=m;m^=6

A full program that prints five hundred numerals (less than 889) of the form [D][C][C][C][L][X][X][X][V][I][I][I], each with a trailing space.

Try it online! (Or check that the results are valid (as per Wolfram's definitions) and that there are 500 here.)

APL (Dyalog Extended), 10 bytes

⍳⌂roman'D'

Try it online!

is the index generator that, given a positive integer, returns the integers from 1 to that, inclusive.

⌂roman is a higher-order function which modifies to make it take and return roman numerals instead of normal numbers.

'D' is 500.

Ruby, 80 bytes

5 bytes saved thanks to Value Ink.

p (0..1892).map{|i|i&=-137;j=""
"IVXLCD".chars{|k|j=k*(i%4)+j;i/=4}
j}.uniq-[""]

Try it online!

Ruby, 85 bytes

n=[]
1893.times{|i|i&=-137;j=""
"IVXLCD".chars{|k|j=k*(i%4)+j;i/=4} 
n|=[j]}
p n-[""]

Try it online!

A full program, outputting the first 500 numbers that contain the only the letters DCLXVI in that order. Output is better formatted if p is changed to puts.

We start with an empty array n and add the output strings to it.

We iterate through i with 2 bits each encoding for the quantity (0 to 3)of D,C,L,X,V,I in each output string. As more than one L or V is not allowed, we zero the more significant bit for L and V by ANDing with -137 = ...1101110111. We do not iterate high enough for there to be more than one D. 1893 iterations are required to reach 500 valid outputs. The final number reached is 875

We build the string for each number in j from right to left. Once complete we OR it with the array n, thereby adding it to the array only if the array does not already contain the string.

The array n inevitably contains the empty string "" (which is generated multiple times during the iteration process) so we delete this before outputting.

Python 3.8+, 176 170 bytes

-6 bytes thanks to Lucenaposition

*c,=zip([500,400,100,90,50,40,10,9,5,4,1],'D CD C XC L XL X IX V IV I'.split())
r=lambda a,k=0:a*'q'and(d:=a//(b:=c[k][0]))*c[k][1]+r(a%b,k+1)
print(*map(r,range(1,501)))

Uses a similar method to this answer using Wolfram Mathematica. 

Python, 170 126 bytes

-44 bytes thanks to tata

c=dict(zip([256,64,32,8,4,1],'DCLXVI'))
for r in range(1,501):
 s=''
 while r:t=max(filter(r.__ge__,c));r-=t;s+=c[t]
 print(s)

Attempt This Online!

R, 15 bytes

as.roman(1:500)

Attempt This Online!

05AB1E, 5 bytes

₄;L.X

Try it online.

Explanation:

₄      # Push 1000
 ;     # Halve it to 500
  L    # Pop and push a list in the range [1,500]
   .X  # Convert each inner integer to a Roman Numeral string
       # (after which the list is output implicitly as result)

JavaScript (Node.js), 84 bytes

_=>(f=(i,p,j=2)=>i?i%2<j?f(i,'DCLXVI'[--i]+p,j-.5)+f(i,p):[]:`
`+p)(6,[]).slice(123)

Try it online!

First generate all strings with pattern D?C?C?C?L?X?X?X?V?I?I?I?. Then slice some characters off so there are exactly 500 numbers remained.

JavaScript (V8), 95 bytes

for(n=501;--n;)print("MCXI".replace(/./g,(c,i)=>["_DLV"[(q=n/6**(3-i)%6)<4||i]]+c.repeat(q&3)))

Try it online!

Output

The lowest value is I (\$1\$) and the highest value is MMCLXII (\$2162\$).

We use:

So this goes \$1\$, \$2\$, \$3\$, \$5\$, \$6\$, \$10\$, \$11\$, \$12\$, \$13\$, \$15\$, \$16\$, \$20\$, ... (from bottom to top).

Wolfram Language (Mathematica), 22 bytes

-2 bytes by att

RomanNumeral@Range@500

Try it online!

Excel, 18 bytes

=ROMAN(ROW(1:500))

Charcoal, 38 bytes

≧×χφF⁴F⪪⍘φDCM²F⪪⍘φLXC²F⪪⍘φVIX²«×Mικλμ→

Try it online! Link is to verbose version of code. Explanation:

≧×χφ

Multiply 1000 by 10. Conveniently, 10000 in base 3 is 111201101. By using a custom string base of, say, VIX, this translates as IIIXVIIVI. Splitting into pairs of characters gives II, IX, VI, IV and I, for the digits 2, 9, 6, 4, and 1.

F⁴F⪪⍘φDCM²F⪪⍘φLXC²F⪪⍘φVIX²

Loop over 0..3 for thousands and 29641 for each of the other three digits.

«×Mικλμ→

Space-separate each output number.

4×5×5×5=500 as desired.

Vyxal 3, 21 bytes

31f4Yfʁkℂf⇄×ᐐ/▦+f501⊖

Vyxal It Online!

what a mess.

thanks to lyxal for the /▦+ trick

31f4Yfʁkℂf⇄×ᐐ/▦+f501⊖­⁡​‎⁠⁠⁠⁠⁠⁠⁠‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁣⁤‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏‏​⁡⁠⁡‌⁤​‎‏​⁢⁠⁡‌⁢⁡​‎‎⁡⁠⁤⁡‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁤⁢‏⁠⁠‏​⁡⁠⁡‌⁢⁣​‎‎⁡⁠⁤⁣‏⁠‎⁡⁠⁤⁤‏‏​⁡⁠⁡‌⁢⁤​‎‎⁡⁠⁢⁡⁡‏‏​⁡⁠⁡‌⁣⁡​‎‎⁡⁠⁢⁡⁢‏⁠‎⁡⁠⁢⁡⁣‏⁠‎⁡⁠⁢⁡⁤‏⁠‎⁡⁠⁢⁢⁡‏‏​⁡⁠⁡‌­
       kℂf⇄            # ‎⁡"MDCLXVI" as a list of characters
           ×           # ‎⁢times...
31f4Yfʁ                # ‎⁣the list [[0, 1, 2, 3], [0, 1], [0, 1, 2, 3], [0, 1], [0, 1, 2, 3], [0, 1], [0, 1, 2, 3], [0, 1]]
# ‎⁤the list is how many times you can 
# ‎⁤safely write each roman numeral char 
# ‎⁤without consideration of the weird rules.
            ᐐ          # ‎⁢⁡drop the last element (artifact of the list construction)
             /         # ‎⁢⁢fold left by...
              ▦+       # ‎⁢⁣outer product concatenation
                f      # ‎⁢⁤flatten
                 501⊖  # ‎⁣⁡take the first 501 (the first is the empty string)
💎

Created with the help of Luminespire.

<script type="vyxal3">
31f4Yfʁkℂf⇄×ᐐ/▦+f501⊖”
</script>
<script>
    args=[]
</script>
<script src="https://themoonisacheese.github.io/snippeterpreter/snippet.js" type="module"/>

Vyxal, 7 bytes

500ɾøṘ⁋

Try it Online!

Simplest answer you're going to get

Explained

500ɾøṘ⁋­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣‏⁠‎⁡⁠⁤‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁢⁣‏‏​⁡⁠⁡‌­
500ɾ     # ‎⁡The range [1, 500]
    øṘ   # ‎⁢converted to roman numerals
      ⁋  # ‎⁣and joined on newlines
💎

Created with the help of Luminespire.

Retina 0.8.2, 81 bytes


¶M¶MM¶MMM
%`$
¶$`C¶$`CC¶$`CD¶$`D
%`$
¶$`X¶$`XX¶$`XL¶$`L
%`$
I¶$`II¶$`IV¶$`V¶$`VI

Try it online! Explanation:


¶M¶MM¶MMM

Thousands: 0, 1, 2 or 3.

%`$
¶$`C¶$`CC¶$`CD¶$`D

Hundreds: 0, 1, 2, 4 or 5.

%`$
¶$`X¶$`XX¶$`XL¶$`L

Tens: 0, 1, 2, 4 or 5.

%`$
I¶$`II¶$`IV¶$`V¶$`VI

Ones: 1, 2, 4, 5 or 6.

4×5×5×5=500 as desired.