Thursday, November 15, 2012

Fibonacci

When we say Fibonacci, some might think of the man, the mathematician, the Fibonacci numbers or even specifically of the following relation:



Or, if you watched (or read) David Mitchell's presentation on iPython at PyHack Workshop #01, you'll recall that it was part of it.

The code was:

 a, b = 0, 1  
 print a,  
 while b < 50:  
   print b,  
   a, b = b, a + b  

Incredibly simple, isn't it? The result of which is:

0 1 1 2 3 5 8 13 21 34


I added the print a, since mathematically speaking, the Fibonacci sequence starts at 0, but most of the time it is displayed starting at 1 (1, 1, 2, 3 etc). I also increased the upper boundary to 50 (it was 10 in the demo).

If you can't read the math, you can at least clearly see that any given member of the Fibonacci series is equal to the sum of the two preceding elements.

So, why am I talking about this?


I have two challenges for my readers. The first, is a Python programming challenge, while the other just requires some power of observation:

  1. modify the above code to have the numbers read (audio) instead of printed, or visualize them graphically, but not as numbers.
  2. look around. Where can you find occurrences of Fibonacci numbers

Bucolic Mix


You'll see where we are going with this on our next mathematical intrigue, perhaps this weekend... In the meantime, do post your answers to the challenge in our comments section below.


See the next step: Fibospeak

No comments:

Post a Comment