Wolfram Language (Mathematica), 136 bytes
Image[#/Max@#]&[p=(#-1)/2;Table[x=Max[4x^2-Max[x+y,3x-y],4y*y-{x+y,3y-x}]+1;0//.a_/;CompositeQ@x:>(x=PrimePi@x;a+1),{y,-p,p},{x,-p,p}]]&
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.