Some interesting generalizations of Sierpinski triangles
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This is the result of playing around with generating analogues of the Sierpinski gasket, partially for a math course project. The method used to calculate the triangles is rather simple:

If one takes Pascal's triangle with 2^n^ rows and colors the even numbers white, and the odd numbers black, the result is an approximation to the Sierpinski triangle. More precisely, the limit as n approaches infinity of this parity-colored 2^n^-row Pascal triangle is the Sierpinski triangle.

Of course, this presents many opportunities for generalizations:

  1. Even numbers are just those congruent to 0 modulo 2 - instead of coloring based on even/odd, color based on congruence to 0 modulo n. This gives a new parameter, the modulus, to expiriment with.

  2. Instead of using a triangle of binomial coefficients, use a triangle of trinomial coefficients, or even one of quartic coefficients.


./executable filename.ppm <multinomial type ∈ {2,3,4}> <modulus ∈ {0..255}> <image size eg. "500x500" with no spaces>

Images are saved as ppm files, and so really should be compressed before doing anything with them! PPM was targeted due to the shear simplicity of the format, and my natural laziness.