#729. Sum of squares
When the green flag is clicked, this script runs. What is the value of the **s** variable?
when green flag clicked set [s v] to (0) set [i v] to (1) repeat (5) change [s v] by ((i) * (i)) change [i v] by (1) end
# When the green flag is clicked
s = 0
i = 1
for _ in range(5):
s += i * i
i += 1
let s = 0, i = 0;
// When the green flag is clicked
s = 0;
i = 1;
for (let j = 0; j < 5; j++) {
s += i * i;
i += 1;
}
💡 Not sure? Build it in Scratch and try it out.