Skip to main content
5 of 5
added 44 characters in body
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282

Jelly,  15  14 bytes

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

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

A full program that accepts a positive integer, \$n\$, on stdin and prints a Jelly representation of the list of the first \$n\$ Sylvester primes.

Try it online!

How?

1‘×$СÆfḟṂṭɗ@/ - Main Link: no arguments
1              - literal one (first value of Current, below)
    С         - collect, repeating...
               - ...times: positive integer, N, from stdin (implicit)
   $           - ...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