Run the following through TeX and it will page-number with primes.
\pageno=2 \newcount\p \newcount\q \newcount\flag \def\advancepageno{ \loop \global\advance\pageno by 1 \p=1 {\loop \advance\p by 1 \q=\pageno \divide\q by \p \multiply\q by \p \ifnum\q=\pageno \global\flag=0 \else \global\flag=1 \q=\p \multiply\q by \p \fi \ifnum\q<\pageno \repeat} \ifnum\flag=0\repeat} % Now some dummy content. \loop \centerline{This is page \the\pageno} \vfil\eject \ifnum\pageno<100\repeat \end
This is not a good program, algorithmically or stylistically, it is just a very simple example of TeX as a programming language.