Skip to main content
1 of 5
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282

Jelly, 13 bytes

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

2‘×$⁸СÆfZFQḣ

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

Try it online!

How?

2‘×$⁸СÆfZFQḣ - Link: positive integer, N
2             - literal two (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)
         Z    - transpose
          F   - flatten
           Q  - deduplicate
            ḣ - head {that} to index {N}
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282