Like all good geeks we love our prime numbers. They're one of the most interesting things to study in mathematics.
Maybe that's why we find this Prime Numbers in a Box project so endearing. It's pretty simple in practice, press a button; get a prime number.
"How many times have you needed the next prime number in a sequence and, like some animal, had to go to a printed table to look it up," says WhiskyTangoHotel. "Well, those days are over."
- Build information: Prime Numbers in a Box
The importance of prime numbers
These numbers are popular in encryption and cryptography. This is because the numbers, which are only divisible by themselves and one, can be multiplied together.
If you multiply two primes together, you get a public key. This number is used to lock data and can be shared freely. But to unlock the data, you need to know the two primes used to generate it.
While it's easy for a computer to generate the key from the two primes, it's very difficult for the computer to get the two numbers from the key.
There's a great video here by Simon Pampena that explains how prime numbers and cryptography work.
Learn about primes by building a box that generates them
While WhiskeyTangoHotels project doesn't create primes for cryptography. Instead, the build just celebrates the existence of these great numbers.
"The project has an entertaining audio effect if you are into numbers," says the maker. "Press a button and Primes in a Box gives an audible (relay click) signal for each non-prime as it waits to display the next found prime. If you enjoy mathematics, you may find this oddly relaxing."
"The Python source is pretty straightforward, explains the maker. "On button press, a pointer to a file containing the first few million primes is indexed and displayed on the LCD. A 5VDC relay clicks to represent the non-primes in between. The rig runs via USB power, and the last found prime is always saved. A handy 'shutdown' button is incorporated to allow the Raspberry Pi to be powered down gracefully if it needs to be moved."
You'll learn a few things about reading and writing to text files in this project. And you'll learn how to use an LCD and relay. More importantly, you'll never be short of primes again. And you might even be your first step towards becoming a cryptographer.