    \documentclass[border=10cm]{standalone}
    
    \usepackage{pgf}
    
    \newcount\ulami
    \newcount\ulamj
    \newcount\ulamlen
    
    \newcount\ulamx
    \newcount\ulamy
    \newcount\ulamdx
    \newcount\ulamdy
    
    \ulami=1 %
    \ulamj=0 %
    \ulamlen=1 %
    \ulamdx=-1 %
    \ulamdy=1 %
    \ulamx=0 %
    \ulamy=0 %
    
    \def\ulamplot#1{%
      \advance\ulami by 1 %
      \advance\ulamj by 1 %
    
      \advance\ulamx by \the\ulamdx %
      \advance\ulamy by \the\ulamdy %
    
      \pgfpathmoveto{\pgfpoint{\the\ulamx cm}{\the\ulamy cm}}
    
      \pgfmathparse{isprime(\the\ulami)}
      \let\r=\pgfmathresult
      \ifnum\r=1
        \pgfpathcircle{\pgfpoint{\the\ulamx cm}{\the\ulamy cm}}{5pt}
      \fi
    
      \ifnum\ulamj=\the\ulamlen %
        \advance\ulamlen by 1 %
        \ulamj=0 %
        \ifnum\ulamdx=1 %
          \ulamdx=-1 %
          \ulamdy=1 %
        \else%
          \ifnum\ulamdx=-1 %
            \ulamdx=0 %
            \ulamdy=-1 %
          \else%
            \ulamdx=1 %
            \ulamdy=0 %
          \fi
        \fi
      \fi
    
      \ifnum#1>0 %
        \advance#1 by -1 %
        \ulamplot{#1}%
      \fi
    }
    
    \begin{document}
    
    \begin{pgfpicture}
      \pgfmathsetmacro{\x}{cos(60)}
      \pgfmathsetmacro{\y}{sin(60)}
      \pgftransformcm{1}{0}{\x}{\y}{\pgfpointorigin}
    
      \pgfpathmoveto{\pgfpointorigin}
      \color{blue}
      \newcount\ulamn
      \ulamn=400
      \ulamplot{\ulamn}
      \pgfusepath{stroke,fill}
    \end{pgfpicture}
    
    \end{document}

