Fibonacci sequence in Music and Python

Math day 5:

Fibonacci Sequence

Fibonacci Sequence and Music

In western music theory, we know an octave including 13 notes:
C, C#, D, D#, E, F, F#, G, G#, A, A#,B, C (1,1#,2,2#,3,4,4#,5,5#,6,6#,7,i) 

Is there anything special about numbers 13?

We notice an octive including 5 sharps notes (C#,D#,F#,G#, A#), and 8 regular notes (C,D,E,F,G,A,B,C).

Now if we go one more step further look at the key distribution on a piano:

The 5 sharp notes are in groups of 2 and 3.

Now, if we re-think about the numbers, we have 2+3=5, 5+8=13.

so we have a sequence of number:  2,3,5,8,13, which is a segment of Fibonacci sequences.

Fibonacci Sequence:


Fibonacci Sequence Definition:

F(1)=1,F(2)=1, F(n)=F(n-1)+F(n-2)

Personally, I think it is very interesting how the Fibonacci Sequence emerged in Music Theory.  

Where is the Fibonacci Sequence come from?

this was a story my previous student told me, there were 2 bunnies on an island, then they started a family, the family members formed Fibonacci sequence ….

castleguard / Pixabay

Now, given a random positive nature number, can we tell it is a Fibonacci Number very quick?

Personally, I could not tell if the number is >100. but, our friend Python can!

A little Fibonacci number Yes or No Python game:

import math

def isPerfectSquare(x):
    return (x==i*i)

def isFibnoacci(n):
    if (isPerfectSquare(5*n*n+4) or isPerfectSquare(5*n*n-4)):
          print (n, "is a Fibonacci Number")
          print(n,"is not a Fibonacci Number" )

Now we can run our  Game Test:

4 is not a Fibonacci Number

168 is not a Fibonacci Number

1000 is not a Fibonacci Number

89 is a Fibonacci Number

Note: The Keypoint is every Fibonacci number is in the form of 5n²+4 or 5n²-4.


The Fibonacci number is so fascinating in music, art and science not only because of its practical use but also it leads to the Golden Ratio!


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social media & sharing icons powered by UltimatelySocial
%d bloggers like this: