Skip to main content
4 of 5
edited body
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282

Jelly, 15 bytes

I'm not convinced this is as terse as possible.

1‘×$⁸СÆfḟṂṭɗ@/

A monadic Link that accepts a positive integer, \$n\$, and yields a list of the first \$n\$ Sylvester primes.

Try it online!

How?

1‘×$⁸СÆfḟṂṭɗ@/ - Link: positive integer, N
1               - literal one (first value of Current, below)
     С         - collect, repeating...
    ⁸           - ...times: chain's left argument = N
   $            - ...action: last two links as a monad - f(Current):
 ‘              -              increment {Current} -> Current + 1
  ×             -              multiply {that] by {Current} -> Current × (Current + 1)
       Æf       - prime factors (vectorises)
              / - reduce by:
             @  -   with swapped arguments:
            ɗ   -     last three links as a dyad - f(right, left):
         ḟ      -       {right} filter discard {left}
          Ṃ     -       minimum of {that}
           ṭ    -       tack to {left}
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282