Home             TeX miscellanea

Prime-numbering pages

Run the following through TeX and it will page-number with primes.


\newcount\p \newcount\q \newcount\flag

        \global\advance\pageno by 1 \p=1
            \advance\p by 1
            \q=\pageno \divide\q by \p \multiply\q by \p
               \q=\p \multiply\q by \p
         \ifnum\q<\pageno \repeat}

% Now some dummy content.

    \centerline{This is page \the\pageno} \vfil\eject


This is not a good program, algorithmically or stylistically, it is just a very simple example of TeX as a programming language.