Skip to main content
3 of 7
Make code fit in screen.
user202729
  • 17.4k
  • 2
  • 37
  • 70

Wolfram Language (Mathematica), 136 bytes

Image[#/Max@#]&[p=(#-1)/2;Table[Tr[1^NestWhileList[PrimePi,Max[4x
x-Max[x+y,3x-y],4y
y-{x+y,3y-x}]+1,CompositeQ]]-1,{y,-p,p},{x,-p,p}]]&

Try it online!


Because TIO doesn't allow image output, I run xxd on TIO to get the hexdump of the image. Unfortunately I didn't install xxd and I don't know how to use xxd I can't add an image. However this is the image generated on my machine with n = 101:

[![Spiral][1]][1] [1]:https://i.sstatic.net/zbOTT.png


Closed form formula of the spiral value taken directly from this answer of mine.


And... explanation.


Image[#/Max@#]&
[
  p=(#-1)/2;
  Table[
    Tr[1^NestWhileList[PrimePi,Max[...]+1,CompositeQ]]-1
    ,{y,-p,p},{x,-p,p}
  ]
]&
user202729
  • 17.4k
  • 2
  • 37
  • 70