TI-BASIC:Sierpinski Triangle

From Learn @ Cemetech
Jump to navigationJump to search

Routine Summary

Displays the Sierpinski Triangle.





Variables Used

L₁, L₂, A, B, C

Calculator Compatibility

TI-83/84/+/SE Author

WeregooseURL: United TI Download

file sierpinski.zip

:Repeat getKey

A [wikipedia:Sierpinski_triangle Sierpinski triangle] is a very common fractal that almost everybody has seen. It consists of a large triangle divided into three smaller triangles, which are then themselves divided into three smaller triangles, and this is repeated infinitely until the triangles are so small you can barely see them.

In order to construct a Sierpinski triangle on the calculator, you need to use the graph screen. Before we can use the graph screen, however, we need to perform some basic Setup. We then create our Variables: two lists (one for the X coordinates and one for the Y coordinates) and two numerics (one for a random X number and one for a random Y number).

Once we have our variables created, we start randomly coming up with places to display the pixels that will make up the triangle. Based on the formula used to generate the triangle, we take the average of the random list values and the random numbers that were generated, and use those for the coordinates of the next pixel. This gets repeated over and over again until either the triangle is completed or you press a key.