3 ms·
Hey all, the giant code block in the article is quite intimidating to read, so I figured I'd post another example here for something developers might be more fa
by ivansavz 4y ago
Hey all, the giant code block in the article is quite intimidating to read, so I figured I'd post another example here for something developers might be more familiar. See below for FizzBuzz in plain TeX:
% Save to fizzbuzz.tex and compile with pdftex, not pdflatex
\def\modulo#1#2{(#1-(#1/#2)*#2)} % a mod n = a-(a/n)*n where / is integer division
\newcount\X
\X=1
\loop
\ifnum \numexpr\modulo{\X}{15} = 0
FizzBuzz
\else
\ifnum \numexpr\modulo{\X}{3} = 0
Fizz
\else
\ifnum \numexpr\modulo{\X}{5} = 0
Buzz
\else
\the\X
\fi
\fi
\fi
\endgraf
\advance \X by 1
\unless \ifnum \X>100
\repeat
\bye