Posts tagged ‘modulo’
I’ve got a prime number trick for you today.
- Choose any prime number p > 3.
- Square it.
- Add 5.
- Divide by 8.
Having no idea which prime number you chose, I can tell you this:
The remainder of your result is 6.
Pretty cool, huh?
I will now fill a bunch of space with quotes and jokes about prime numbers to prevent you from seeing the spoiler explanation below. But you can skip straight to the bottom if you’re not interested in the other stuff or if you just can’t control yourself.
Mark Haddon, author of The Curious Incident of the Dog in the Night-time, wrote the following:
Prime numbers are what is left when you have taken all the patterns away. I think prime numbers are like life. They are very logical, but you could never work out the rules, even if you spent all your time thinking about them.
(Incidentally, if you haven’t read that book, you should. Amazon reviewer Grant Cairns said it better than I could: “The integration of the mathematics into the fiction is better than any other work that I know of. The overall effect is a beautiful story that any maths fans will find hard to read without the tissue box close at hand.”)
Israeli mathematician Noga Alon said that he was interviewed on Israeli radio, and he mentioned that Euclid proved over 2,000 years ago that there are infinitely many primes. As the story goes, the host immediately interupted him and asked:
Are there still infinitely many primes?
And of course there’s this moldy oldie:
Several professionals were asked how many odd integers greater than 2 are prime. The responses were as follows:
Mathematician: 3 is prime, 5 is prime, 7 is prime, and by induction, every odd integer greater than 2 is prime.
Physicist: 3 is prime, 5 is prime, 7 is prime, 9 is experimental error, 11 is prime, …
Engineer: 3 is prime, 5 is prime, 7 is prime, 9 is prime, 11 is prime, …
Programmer: 3 is prime, 5 is prime, 7 is prime, 7 is prime, 7 is prime, …
Marketer: 3 is prime, 5 is prime, 7 is prime, 9 is a feature, …
Software Salesperson: 3 is prime, 5 is prime, 7 is prime, 9 will be prime in the next release, …
Biologist: 3 is prime, 5 is prime, 7 is prime, the results for 9 have not yet arrived…
Advertiser: 3 is prime, 5 is prime, 7 is prime, 11 is prime, …
Lawyer: 3 is prime, 5 is prime, 7 is prime, there is not enough evidence to prove that 9 is not prime, …
Accountant: 3 is prime, 5 is prime, 7 is prime, 9 is prime if you deduct 2/3 in taxes, …
Statistician: Try several randomly chosen odd numbers: 17 is prime, 23 is prime, 11 is prime, …
Professor: 3 is prime, 5 is prime, 7 is prime, and the rest are left as exercises for the student.
Psychologist: 3 is prime, 5 is prime, 7 is prime, 9 is prime but tries to suppress it, …
Card Counter: 3, 5, and 7 are all prime, but I prefer 21.
Explanation of the Prime Number Trick
We are trying to show that (p2 + 5) mod 8 = 6. This is equivalent to showing that (p2 ‑ 1) mod 8 = 0, or that (p + 1)(p ‑ 1) is divisible by 8.
Because p > 3 and is prime, then either p = 1 mod 4 or p = 3 mod 4. Consequently, it must be the case that (a) p + 1 = 2 mod 4 and p ‑ 1 = 0 mod 4 or (b) p ‑ 1 = 2 mod 4 and p + 1 = 0 mod 4. That is, both numbers will be even, and at least one of them will be a multiple of 4. For either (a) or (b), the product (p + 1)(p ‑ 1) will be a multiple of 8. Q.E.D.
There aren’t too many math humorists in the world, and, for a very brief period of time, I was in high demand. (Relatively speaking, of course.) A talent agent once saw me give a presentation called Puns and Puzzles, which mixes number tricks with math jokes. After the show, he told me about a cruise line that caters to a very intellectual audience, and he asked if I’d be willing to perform on a ship. A month later, I was sailing the seven seas and, occasionally, making people laugh.
Aboard the Princeps Mathematicorum, audiences were generally polite. But one night, a rude mathematician sat in the front row with an even ruder parrot on his shoulder. Halfway through my act, I presented the following puzzle:
- Look at the 16 digits from one of your credit cards. Create two eight‑digit numbers, one consisting of all the digits in odd positions (that is, the first, third, fifth, and so on), the other consisting of all the digits in even positions (second, fourth, sixth, and so on).
- Add the digits of the first eight‑digit number, and double the result. Write it down.
- Add the digits of the second eight‑digit number. Write it down.
- How many of the digits in the first eight‑digit number are 5 or greater? Write it down.
- Now add the results of steps 2, 3, and 4.
I then magically revealed the last digit of each audience member’s result.
The mathematician rolled his eyes at the trick, and the parrot squawked, “This is just the Luhn system — brrrraaaaaak! — for credit cards! Of course the result will be 0!”
His outburst surprised me. I don’t like when my secrets are revealed. I was frustrated, but there was little I could do. It’s not like I could have an argument with a parrot. The rest of the show went poorly, and I left the stage distraught.
The next night, I had another show. But the mathematician and his bird were back, once again seated in the front row.
Wanting to avoid a repeat, I used a different puzzle:
- Take a four‑digit number.
- Scramble the digits to form a different four‑digit number.
- Subtract the smaller number from the larger number.
- Now, take the digits of the result, and add them together.
I then showed the following chart and magically predicted the symbol that would be associated with each audience member’s result:
The parrot shrieked, “Of course it will be omega! Any two numbers created from the same digits — brrrraaaaaak! — will be congruent modulo 9! The sum of the digits will always be a multiple of 9.”
Once again, he ruined my trick. I was angry, and I went to bed that night completely dismayed. But my dejection was short-lived — during the night, we hit an iceberg, and the boat sank.
I was submerged into freezing cold water. A piece of the deck was floating on the surface, and I pulled myself onto it. To my dismay, the parrot was perched on the other end. I shot him an angry look. He said nothing. I said nothing. We floated for several hours in silence, shivering, just staring at one another.
Finally, he spoke.
“Okay,” he said, “I give up. How the hell did you make the ship disappear?”
Of course, you could make a Magic Heart for your special someone. But if Arts ‘n Crafts aren’t your thing, just copy one of the following poems onto a blank card, and your sweetie will be swooning!
Roses are #FF0000,
Violets are #0000FF,
Hexadecimal is awesome,
And so are you!
Roses are #FF0000,
Leaves are #00C000,
We express colors
In powers of 16!
What’s that? You don’t speak RGB? Okay, then try this poem by Michael Stueben called Valentine:
You are the fairest of your sex,
Let me be your hero;
I love you as one over x,
as x approaches zero.
For my money, though, the best math love poem is “Square Root of Three” from Harold and Kumar Escape from Guantanamo Bay.
Maybe you’ve been together a long time, and you no longer need to woo your sweetie. In that case, just make him or her smile with this poem from John McClelland…
A lady of 80 named Gertie
Had a boyfriend of 60 named Bertie.
She told him emphatically
That viewed mathematically
By modulo 50, she’s 30.
Or perhaps you’ve just gotten out of a relationship and are currently single. Here’s a poem you can send to your ex.
Rose are red,
Violets are blue,
Our love is like a poem
That doesn’t rhyme.
Or maybe you really don’t feel like celebrating. You’ve been jilted, and you are officially anti‑Valentine’s Day. The following MJ4MF original poem might be more to your liking.
My belief in love was completely destroyed
The day you ripped out my cardioid.
Your actions and words never equated;
Your emotions, randomly generated.
Up and down again, like the curve of sine —
My screwed-up, degenerate Valentine.
So I’ll tell you abruptly, and this you can quote:
F**k this day, and kiss my asymptote!