Version 1. Stores fibonacci(n) and fibonacci(n+1) in the variables a and b up to n=10. Waits 1 second between each iteration for visibility.
![](https://silveiraneto.net/wp-content/uploads/2021/11/745F07CF-FF1D-4C1A-AA23-C692024CEA5B-1024x715.png)
Pseudocode:
a = 0
b = 1
for (10) {
wait(1)
b = a + b
a = b - a
}
Version 2. Blinks a powered up hub (88009 or any other). The led blinks the number of times of fibonacci(n) sequence.
![](https://silveiraneto.net/wp-content/uploads/2021/11/330901E5-F4F9-485E-9B69-0741EA064334-1024x715.png)
Pseudocode:
a = 0
b = 1
light(RED)
for (10) {
wait(1)
b = a + b
a = b - a
c = b
while (c!=0) {
light(GREEN)
wait(0.5)
light(RED)
c = c - 1
}
}
It may look like a wait is needed at the second red light but in practice each block takes a little delay to execute.