## Programmatically-Generated LaTeX Sieve of Eratosthenes

(tl;dr: see PDF here). For a top-secret joke project I am learning to program in LaTeX as if it were a general-purpose 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 well-known 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 TeX-induced insanity in my Github repository.

I first implemented FizzBuzz using the LaTeX packages1 "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 colour-coded 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.

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