computer science education - python prime numbers

Have you ever wondered what the first 500 prime numbers sound like? (Of course you have). Well, wonder no longer, as with the help of Python, it’s easy to find out!

The is no known pattern to the primes, a fact which has tantalized mathematicians since ancient times, since there are nonetheless hints of pattern – a kind of ordered chaos is you will. For example, in the sound clip above, can you hear how the higher notes (representing prime numbers) frequently come in pairs? These are known as twin primes.

What else do you notice when you listen to the track?

The track was made using Jython Music which is a completely free, open source project that makes exploring sound with Python easy and fun. You can also make music in your browser with Jython Music.

There is also a great book availabe that explores computer science through making music using Jython Music.

For those curious to try it themselves, download Jython Music (or use this link to an online version), open a new file, paste in the code below and hit play. Of course you can experiment by changing some of the values to see what happens. For example you can easily speed up/slow down the piece by adjusting the tempo value.

Have fun!

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}