# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 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}]]& [Try it online!](https://tio.run/##NclBC4IwGMbxe59CFMRya808JQshOnQILLqNFauWDZqOMniH9NnNim6/5/8Y2VyVkY0@ye7CupWRpeIBWUvIAxFyy6IA0yFJsp083hQH1j88hX2CP4DYoSlgJ1DqRg633@0wvERMswkhY3kg2aI2tn7oRm1ymM0jYMVdG1XoHDIZ0yFqHcIW2Rdq4Qchwk6b0mPehdMJFYMl2PrecL@PY1uVPvJ6icH2WXEf4Oz9u@je "Wolfram Language (Mathematica) – 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](https://codegolf.stackexchange.com/a/154458/69850) of mine.