Fractals are geometric patterns that repeat at smaller scales through self-similarity. In programming, we create them using recursion—a function that calls itself with smaller inputs until reaching a base case (when order == 0, draw a straight line).
The Koch Snowflake replaces the middle third of each line segment with an equilateral triangle bump (turning left $60^\circ$, right $120^\circ$, left $60^\circ$). At each step the perimeter grows by $4/3$, yielding an infinite perimeter enclosed within a finite area!
Now you try. Change the recursion order from 3 to 2 or 4, or change the turn angles inside the recursive step to see new geometric fractals emerge!
Type your code here:
See your results here:
Click Run Code to watch the turtle construct a 3rd-order Koch Snowflake in real-time!
1. Try changing koch(3, 240) to koch(1, 240), then koch(2, 240), and finally koch(4, 240) to see the fractal detail multiply!
2. Try changing fast(10) to fast(1) to watch every step slowly, or fast(30) for rapid drawing.
Share your code
Show a friend, family member, or teacher what you've done!