A small script to help visualize the euclidean algorithm for computing the greatest common divisor by tilling a rectangle with the biggest possible squares. The gcd will be the side of the smallest square. Check a worked example.
You'll need python and pdflatex. Just type
python gen.py <a> <b>
in the command line replacing <a>
and <b>
positive integers.
The script will then generate a file named final.tex
and run pdflatex on it.
If you want the tikz code to use elsewhere just copy from the .tex file. The additional
argument beamer
will generate a beamer presentation with pauses so that the squares
appear one at a time.
Running
python gen.py 21 13
will generate a pdf with the following image:
While
python gen.py 21 8 beamer