I want to avoid using \tmp. Is it possible to remove it while keeping the same output?

% Declare counters.
\newcount\pages% \pages is given so you cannot remove it!
\newcount\x
\newcount\tmp
% Initializing.
\pages=9% Try it for an odd or even integer.
\tmp=\pages
\advance\tmp by 1
\x=1
\loop
\ifnum\x<\tmp
\noindent\hfill\the\x
\advance\x by 1
\ifnum\x>\pages
\hfill\null\endgraf
\else
\hfill\the\x\hfill\null\endgraf
\fi
\advance\x by 1
\repeat
\bye
Note: Please don't use e-TeX extension as I am learning Knuth's original TeX right now.