Maths Inside the Drawing
change is only addition, which sounds limited until you notice that a loop turns addition into multiplication, and a growing step into a spiral. The real skill is predicting the numbers on paper first, then letting the turtle confirm you were right.
π‘ The idea
Repeated addition inside a loop builds a sequence, and you can predict it before you run it.
- Each round adds the same amount, so the values form an arithmetic sequence.
- The last value is first + (n - 1) x step. Work it out before running the code.
- Adding the same amount n times is the same as multiplying by n.
- Use change with a negative number to shrink instead of grow.
- Star Blocks has no multiply or divide, so you do that arithmetic yourself.
π Words to know
- sequence
- a list of numbers made by a rule
- arithmetic sequence
- a sequence that adds the same amount each time
- predict
- work out the answer before running the program
π Watch this
A spiral of twelve steps. The last step is 10 + 11 x 8 = 98 long, and the turns total 360.
set side 10 set turn 30 repeat 12 [ forward side right turn change side by 8 ]
βοΈ Your turn
- Work out the last step on paper, then run the code and check the drawing.
- Change the growth from 8 to 4. What is the last step now?
- Change set turn 30 to set turn 45 and work out how many full circles that makes.
- Try change side by -5 with set side 120 and describe the result.
- Add up all twelve steps. That total is the length of the whole line.
π― Challenge: Build a spiral with a step that grows by 3 and a turn of 45. Before you run it, work out how long the last step will be.
Show me one answer
set side 20 set turn 45 repeat 16 [ forward side right turn change side by 3 ]
Your program