Created
May 25, 2022 13:08
-
-
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...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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