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

Jelly, 15 15  14 bytes

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

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

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

Try it online!Try it online!

How?

1‘×$⁸СÆfḟṂṭɗ@1‘×$СÆfḟṂṭɗ@/ - Main Link: positive integer,no Narguments
1               - literal one (first value of Current, below)
     С         - collect, repeating...
               - ...times: chain'spositive leftinteger, argumentN, =from Nstdin (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}

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}

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}
edited body
Source Link
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282

Jelly, 15 bytes

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

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

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

Try it online!Try it online!

How?

2‘×$⁸СÆfḟṂṭɗ@1‘×$⁸СÆfḟṂṭɗ@/ - Link: positive integer, N
21               - literal twoone (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}

Jelly, 15 bytes

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

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

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

Try it online!

How?

2‘×$⁸СÆfḟṂṭɗ@/ - 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)
              / - reduce by:
             @  -   with swapped arguments:
            ɗ   -     last three links as a dyad - f(right, left):
         ḟ      -       {right} filter discard {left}
          Ṃ     -       minimum of {that}
           ṭ    -       tack to {left}

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}
Post Undeleted by Jonathan Allan
added 214 characters in body
Source Link
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282

Jelly, 1215 bytes

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

2‘×$⁸СÆfFQḣ2‘×$⁸СÆfḟṂṭɗ@/

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

Try it online!Try it online!

How?

2‘×$⁸СÆfFQḣ2‘×$⁸СÆfḟṂṭɗ@/ - 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)
         F     / - flattenreduce by:
          Q   @  - deduplicate  with swapped arguments:
            ɗ   - head    last three links as a dyad - f(right, left):
         ḟ      -       {right} filter discard {left}
          Ṃ     -       minimum of {that} 
 to index         ṭ    -       tack to {Nleft}

Jelly, 12 bytes

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

2‘×$⁸СÆfFQḣ

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

Try it online!

How?

2‘×$⁸СÆfFQḣ - 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)
         F   - flatten
          Q  - deduplicate
            - head {that} to index {N}

Jelly, 15 bytes

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

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

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

Try it online!

How?

2‘×$⁸СÆfḟṂṭɗ@/ - 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)
              / - reduce by:
             @  -   with swapped arguments:
            ɗ   -     last three links as a dyad - f(right, left):
         ḟ      -       {right} filter discard {left}
          Ṃ     -       minimum of {that} 
           ṭ    -       tack to {left}
Post Deleted by Jonathan Allan
deleted 44 characters in body
Source Link
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282
Loading
Source Link
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282
Loading