Skip to content

Instantly share code, notes, and snippets.

@ivanistheone
Created May 25, 2022 13:08
Show Gist options
  • Save ivanistheone/317cd3c4f79e94301fd625d0cd16bc4d to your computer and use it in GitHub Desktop.
Save ivanistheone/317cd3c4f79e94301fd625d0cd16bc4d to your computer and use it in GitHub Desktop.
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