#909. Fibonacci
When the green flag is clicked, this script runs. What number will the cat say?
when green flag clicked set [a v] to (0) set [b v] to (1) repeat (15) set [t v] to ((a) + (b)) set [a v] to (b) set [b v] to (t) end say (a)
# When the green flag is clicked
a = 0
b = 1
for _ in range(15):
t = a + b
a = b
b = t
print(a)
let a = 0, b = 0, t = 0;
// When the green flag is clicked
a = 0;
b = 1;
for (let i = 0; i < 15; i++) {
t = a + b;
a = b;
b = t;
}
console.log(a);
💡 Not sure? Build it in Scratch and try it out.