KeithSchwarz.com | Back | Forward |

The key to this trick is that the pairs of numbers at the top of the page are not at all random. They all follow a consistent pattern.

In number theory and computer science, the *modulus* operator (mod) yields the remainder of the first number when divided by the second. For example, `7 mod 3 = 1` because `7 / 3 = 2 R 1`. Likewise:

14 mod 7 = 0

64 mod 6 = 4

51 mod 9 = 6

88 mod 2 = 0

There is a very special property of modular arithmetic that enables this trick to work.

`
if x mod n = j and y mod n = k, then (x + y) mod n = (j + k)
`

This may be a bit complicated to understand, but basically it means that the mod of the sum of two numbers is the sum of those two numbers' mods.

The question, of course, is how this relates to the trick. Simple.

Here is a sample set of numbers.

36 37 | 12 38 | 0 16 | 24 44 | 1 2 |

25 4 | 13 20 | 14 40 | 26 32 | 28 8 |

Now, here's that same table again, but this time mod 12.

0 1 | 0 2 | 0 4 | 0 8 | 1 2 |

1 4 | 1 8 | 2 4 | 2 8 | 4 8 |

As you can see, there is a pattern here. But more importantly, here's the *sum* of all the numbers in the table, mod 12.

1 | 2 | 4 | 8 | 3 |

5 | 9 | 6 | 10 | 0 |

The trick lies in the organization of the 4x5 table. All the numbers in each row yield the same result when mod-ded by 12. Thus, when you click on a row, the computer doesn't know *exactly* what number you chose that's in that row, but it knows what the number, mod 12, is. It then adds that modular number to a running total. When you click on the second row, it again adds the modular total to the running total. Once you've clicked the second row, though, the computer has a modular total that indicates what pair you chose, since the modular sums are the same. For example, if the modular sum is 8, the computer knows that you chose the 4th pair on the first row and thus can pinpoint your total.

In short, the math is very complex, but the trick is simple.