ProgrammaticallyGenerated LaTeX Sieve of Eratosthenes
(tl;dr: see PDF here). For a topsecret joke project I am learning to program in LaTeX as if it were a generalpurpose language. LaTeX is my favourite way to write scientific papers, but no one should use it for programmatic logic. Along the way I have implemented a Sieve of Eratosthenes, a wellknown algorithm for finding prime numbers. The natural typesetting ability of LaTeX allows me to easily generate an intuitive representation of the inner working of the algorithm.
Watch my rapid descent into TeXinduced insanity in my Github repository.
I first implemented FizzBuzz using the LaTeX packages^{1} "ifthen", "intcalc", and "forloop", which got me conditionals, simple arithmetic, and a useful control structure, respectively.
Then I found a brilliant "array" mechanism on the TeX StackExchange, which I adapted to allow me to implement a simple sieve (source), the output of which is an ugly numeric list (PDF).
But I thought I could have LaTeX represent the internal state of the algorithm as a colourcoded matrix at each point in its operation. I'm quite pleased with the result (PDF), (source) which I think is an intuitive representation of how this simple algorithm works.

This can all be done in raw TeX, but I'm not a maniac. ↩