Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FizzBuzz of first 100 numbers written using TeX macros. TeX is a very strange programming language, but hey it works...
% 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment