# Simon’s Fibonacci function and Fibonacci counter in p5.js

Simon came up with this Fibonacci function while taking a walk downtown: ```f(0) = 0

f(1) = 1

f(n) = f(n-1)+f(n-2)```

When we got home, he used the function to build a Fibonacci counter in p5.js:

You can play with Simon’s Fibonacci counter online at: https://alpha.editor.p5js.org/simontiger/sketches/Skhr3o8Gf

The idea about the Fibonacci function struck Simon when he was looking down at the cobbles under his feet. “Look, Mom! It’s a golden rectangle!”, he shouted: He had read that golden ratio has a direct connection to the Fibonacci sequence. The same evening, he took out his compasses to draw a golden rectangle (this time not his own invention, but following the steps from his Murderous Math book):  If you turn the page, the smaller rectangle is a golden rectangle as well, and if you slice a square off of it, the remaining rectangle will also have the golden proportions. You can continue doing this infinitely. The sizes of the rectangles will exactly correspond to the numbers in the Fibonacci sequence, which makes these drawings an illustration to the sequence. The next day, Simon showed his function to his math teacher. Below are the Fibonacci sequence numbers he got through his selfmade JavaScript program. After a certain number, the computer started taking too long to compute the following number in the sequence (several seconds per number), but didn’t crash. 