The famous Sierpiński Gasket!
Idea (in simplest words) is to create equilateral triangles within a parent equilateral triangle, in such a manner that after each iteration, three more small triangles are made that perfectly fit in the parent triangle.
In this implementation, the max number of triangles you see is: 9840. This number is generalized based on the formula [(3^n)/2] - 1
, which at each n
, corresponds to a round of iterations which fill the entire parent triangle with equally sized child triangles (n
is kept to 9 in this example).