Here are two programs I created for my TI84+CE that draws a Sierpinski square (well, 2/3rds of one anyways). The first one draws a small square, creating a larger square as it goes. The second one draws pixels at different screen positions filling in the pattern as it runs. Because of the screen size, I can only draw 2/3rds of the square at the size I’m drawing. It takes 6min, 30seconds to complete the drawing. There are several FOR loops, but at some point I might try to make it recursive on my calculator. I have it recursive on my iPad which draws the full square instantly. I also have code on my iPad that draws an 81x81x81 Sierpenski cube in about 2 seconds.
Just a note, there are 2 programs listed. They should be loaded separately.
I changed the 81 value for loops to 0 so the program stops after drawing 2/3rds even though I have an if statement which prevents drawing off screen.
Code:
Just a note, there are 2 programs listed. They should be loaded separately.
I changed the 81 value for loops to 0 so the program stops after drawing 2/3rds even though I have an if statement which prevents drawing off screen.
Code:
ClrDraw
For I,-81,0,81
For J,-81,81,81
If I≠0 or J≠0:Then
For G,-27,27,27
For H,-27,27,27
If G≠0 or H≠0:Then
For E,-9,9,9
For F,-9,9,9
If E≠0 or F≠0:Then
For C,-3,3,3
For D,-3,3,3
If C≠0 or D≠0:Then
For A,-1,1,1
For B,-1,1,1
If A≠0 or B≠0:Then
A+C+E+G+I+121→Y
B+D+F+H+J+132→X
If Y≥0 and Y≤164:Then
Pxl-On(Y,X,RED)
End:End:End:End
End:End:End:End
End:End:End:End
End:End:End:End
ClrDraw
For I,-1,1,1
For J,-1,1,1
If I≠0 or J≠0:Then
For G,-3,3,3
For H,-3,3,3
If G≠0 or H≠0:Then
For E,-9,9,9
For F,-9,9,9
If E≠0 or F≠0:Then
For C,-27,27,27
For D,-27,27,27
If C≠0 or D≠0:Then
For A,-81,0,81
For B,-81,81,81
If A≠0 or B≠0:Then
A+C+E+G+I+121→Y
B+D+F+H+J+132→X
If Y≥0 and Y≤164:Then
Pxl-On(Y,X,RED)
End:End:End:End
End:End:End:End
End:End:End:End
End:End:End:End