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}]]&
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.
(* Rescale the matrix # from [0..Max@#] to [0..1] *)
#/Max@#
(* Create an image from the data. *)
Image[ ]& [
p=(#-1)/2;
(* Construct a table of values of s(f(x,y)). *)
Table[
(* Repeatedly apply PrimePi function while the value is
still Composite. The second argument is taken directly
from the other answer. *)
NestWhileList[PrimePi,Max[...]+1,CompositeQ]
(* Count the number of values used minus one. *)
Tr[1^ ]-1
(* Let the range of x and y be -p..p. *)
,{y,-p,p},{x,-p,p}
]
]&