Skip to main content
added 623 characters in body
Source Link

Jelly, 16 bytes

ÆRµ+Ø+Ḥ¤ẒẸ”*xṭ)K

Try it online!

How it works

ÆRµ+Ø+Ḥ¤ẒẸ”*xṭ)K - Main link. Takes N on the left
ÆR               - Yield the prime range until N
  µ           )  - Over each prime P between 2 and N:
       ¤         -   Group into a nilad:
    Ø+           -     Builtin; [1, -1]
      Ḥ          -     Unhalve; [2, -2]
   +             -   Add to P;  [P+2, P-2]
        Ẓ        -   Is prime?
         Ẹ       -   Are any true? Either 1 or 0
          ”*x    -   Repeat "*" that many times
             ṭ   -   Append to P, yielding [P, "*"] or [P, ""]
               K - Join by spaces

Jelly, 16 bytes

ÆRµ+Ø+Ḥ¤ẒẸ”*xṭ)K

Try it online!

Jelly, 16 bytes

ÆRµ+Ø+Ḥ¤ẒẸ”*xṭ)K

Try it online!

How it works

ÆRµ+Ø+Ḥ¤ẒẸ”*xṭ)K - Main link. Takes N on the left
ÆR               - Yield the prime range until N
  µ           )  - Over each prime P between 2 and N:
       ¤         -   Group into a nilad:
    Ø+           -     Builtin; [1, -1]
      Ḥ          -     Unhalve; [2, -2]
   +             -   Add to P;  [P+2, P-2]
        Ẓ        -   Is prime?
         Ẹ       -   Are any true? Either 1 or 0
          ”*x    -   Repeat "*" that many times
             ṭ   -   Append to P, yielding [P, "*"] or [P, ""]
               K - Join by spaces
Source Link

Jelly, 16 bytes

ÆRµ+Ø+Ḥ¤ẒẸ”*xṭ)K

Try it online!