# Sieve of Eratosthenes [closed]

I have look at the answer from @AlainMatthes at Sieve of Eratosthenes in tikz where I have added the suggested extra code:

Code

\documentclass{article}
\usepackage{tikz}

\makeatletter
\tkzutil@ifundefined{pgfmath@function@isprime}{%
\newif\ifpgf@unknown
\newif\ifpgf@isaprime
\pgfmathdeclarefunction{isprime}{1}{%
\begingroup%
\pgf@unknowntrue
\c@pgfmath@counta#1\relax%
\ifcase#1\relax
% |#1| = 0
\pgf@isaprimefalse\pgf@unknownfalse
\or
% |#1| = 1
\pgf@isaprimefalse\pgf@unknownfalse
\or
% |#1| = 2
\pgf@isaprimetrue\pgf@unknownfalse
\or
% |#1| = 3
\pgf@isaprimetrue\pgf@unknownfalse
\else
% |#1| > 3
\ifodd#1\relax
\else
\pgf@isaprimefalse\pgf@unknownfalse
\fi
\fi
\ifpgf@unknown
\c@pgfmath@countd=\thr@@ \pgf@isaprimetrue
\loop
\c@pgfmath@countb=\c@pgfmath@counta
\divide\c@pgfmath@countb by\c@pgfmath@countd
\ifnum\c@pgfmath@countb>\c@pgfmath@countd \pgf@unknowntrue
\else\pgf@unknownfalse\fi
\multiply\c@pgfmath@countb by\c@pgfmath@countd
\ifnum\c@pgfmath@countb=\c@pgfmath@counta
\global\pgf@isaprimefalse\pgf@unknownfalse\fi
\repeat
\fi
\ifpgf@isaprime
\def\pgfmathresult{1}%
\else
\def\pgfmathresult{0}%
\fi
\pgfmath@smuggleone\pgfmathresult%
\endgroup
}}{}
\makeatother

\begin{document}

\begin{tikzpicture}[y=-1cm]
\foreach \x in {0,...,9}
\foreach \y in {1,...,10}
{ \draw (\x,\y) +(-.5cm,-.5cm) rectangle ++(.5cm,.5cm);
\pgfmathtruncatemacro{\nb}{\x*10+\y}
\ifnum\nb=1 \def\pgfmathresult{1}
\else
\node[minimum size= 1cm](last) at (\y-1,\x+1) {\nb};
\pgfmathisprime{\nb}
\fi
\ifnum\pgfmathresult=0
\draw[red](last.north west)--(last.south east)
(last.north east)--(last.south west);
\fi}
\end{tikzpicture}

\end{document}


When I compile, I get the following error:

! Undefined control sequence.
l.5 \tkzutil@ifundefined
{pgfmath@function@isprime}{%


What am I doing wrong?

## closed as too localized by zeroth, Svend Tveskæg, Speravir, T. Verron, WernerMar 3 '13 at 19:34

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

• its not \tkzutil@ifundefined but \pgfutil@ifundefined. Hence, it doesn't recognize tkz...ned. :) I think maybe Alain has defined it in his package tkz-euclid? I don't believe it to be standard. – zeroth Mar 3 '13 at 18:55