# Page numbering affected by recursive programming

I asked this question How to do recursive program with latex and got the following excellent answer by @JosephWright

\documentclass{article}

% Set the first practice date
\ThisDay{7}
\ThisMonth{2}
\ThisYear{2019}

%... the number of days between lectures
\newcommand*{\lecturegap}{7}

\makeatletter
\newcounter{holiday}
\stepcounter{holiday}%
\@namedef{holiday\arabic{holiday}}{%
\def\holidayDay{#1}%
\def\holidayMonth{#2}%
\def\holidayYear{#3}%
}%
}
\makeatother
\newcommand*{\holidayDay}{0}
\newcommand*{\holidayMonth}{0}
\newcommand*{\holidayYear}{0}
\addholiday{19}{6}{2019} % qua Aniv. Rib. Preto

\newif\ifholiday
\newcommand*{\groupA}{}
\makeatletter
\newcommand*{\nextprac}{%
\holidayfalse
\count0=1 %
\loop
\ifnum\count0>\value{holiday}\else
\@nameuse{holiday\number\count0 }%
\ifnum 0%
\ifnum\holidayDay=\day1\else0\fi
\ifnum\holidayMonth=\month1\else0\fi
\ifnum\holidayYear=\year1\else0\fi
=111 %
\holidaytrue
\count0=\value{holiday}%
\else
\fi
\repeat
\ifholiday
\expandafter\nextprac
\else
\ifx\groupA\empty
\edef\groupA{%
{\day=\the\day\month=\the\month\year=\the\year\relax\noexpand\today}}%
\expandafter\expandafter\expandafter\nextprac
\else
\section*{\groupA\space$\parallel$ \today}%
\def\groupA{}%
\fi
\fi
}

\begin{document}

\nextprac
Practice one

\nextprac
Practice two

\nextprac
Practice three

\nextprac
Practice four

\nextprac
Practice five

\nextprac
Practice six

\nextprac
Practice seven

\nextprac
Practice eight

\nextprac
Practice nine

\nextprac
Practice ten

\end{document}


However, a few months latter, I realized that this code affects page numbering. But I cannot figure out how it is affected nor how to fix it.

The only thing I realized is that the page number becomes the exact number of holidays created by \addholiday command.

My question is: how to restore page numbering without leaving the presented code away?

• \count0 refers to the page number. – egreg Mar 25 at 13:26
• @JosephWright should stick to expl3 then he wouldn't using \count0 as loop variable ;-) (he probably wanted to use \count@) – Ulrike Fischer Mar 25 at 13:27

You're using \count0 in the wild, which contains the page number.
Change all occurrences of \count0 into \@tempcnta