Pick a two-digit number. Anything from 0 to 99 inclusive will work, because the single digit numbers can be considered to have a leading zero. Add the digits together. Subtract that from the original number. So if you started with 12, you add the digits to get 3, and subtract that from 12 to get 9 as your final answer.

Ok well that’s a bit mundane and boring, though it sounds like the setup to a magic trick. And so it is. We’ll worry about the trick in a minute. First we’d like to write that algorithm as a function. First we’ll have to figure out a way to extract the digits from the overall two-digit number. It’s not hard. If the first digit is *a* and the second digit is *b*, then the actual number is (10a + b), because the digit a is in the 10’s place and the digit b is in the one’s place. So if you chose your particular two digit numbers to have your prefered a and b, the function describing the final answer will be:

Thus the final answer doesn’t even depend on what the second digit is at all. It will just be 9 times the first digit. And so if a magician had a list of numbers with magical symbols next to them, he might (for instance) claim to be able to pick out the symbol corresponding to your result. He’d sure enough be able to do it, if he subtly picked the same symbol for each multiple of 9.

Which is what any of the dozens of mind-reader sites of this variety actually do. Here’s one (turn down your speakers, it’s a little loud). It’s not a new trick, and this Sunday Function is far from the first explanation online. But it’s a classic, and darned if it isn’t just stupidly fun. Similar techniques will work on any number of other numerical magic tricks. All of those kinds of tricks make for particularly enjoyable intellectual exercises. Scientists and mathematicians should be especially happy to meet challenges of this sort, since as a rule they’re pretty bad at figuring out other kinds of magic. At least I am anyway. I’m used to equations, which usually can’t do sleight of hand. Usually.