I recently made a Facebook post on the Scientific American article New Take on an Ancient Method Improves Way to Find Prime Numbers. The article focused on a mathematicians work in improving the Sieve of Eratosthenes to determine if a number is prime. If you are unfamiliar with this ancient algorithm, then this video will be instructive:
Anyway, this got me into thinking of developing a prime number checking program – but in the opposite direction: using the most basic algorithm to check if a sequence of numbers is prime.
Sounds crazy, right? Well, just hear me out. What I want to do is to develop a cool demonstration that shows each number being tested (the speed of program execution will be a variable, btw), and the result of the testing – whether the number is prime or composite.
Take your calculator – it has to have a factorial function (n!). Punch in 0.5, and then hit the factorial key (n!). Then hit the square function key (x2). Then multiply the result by 4. Do you recognize the final result? That’s right – Pi!!
Check out this video for a demonstration and an explanation:
WOW! I have to admit that I failed on this one, so don’t feel bad if you do too!
I am not sure why this math trick works so well. I think it might be because your brain is conditioned into a calculation mode that causes you to come up with an incorrect figure, even though you believe it to be correct. Did you get it right, or were you fooled too?