Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have been studying algorithms for a project im developing, and found this card trick,

can any matemathical guru help me understand the algorithm behind??

card trick

thanks a lot!

share|improve this question
1  
It's generally a rule of thumb to make questions self-contained. Especially so if you're linking to youtube instead of a readable document or webpage. I suggest providing a reasonable summary of the video. –  anon Aug 4 '11 at 23:49
    
hi thanks, so should I write what the guy says in the video? –  MaKo Aug 4 '11 at 23:50
    
@MaKo, that would be a good idea, also read my answer. –  picakhu Aug 4 '11 at 23:56
1  
In order to understand the explanation I recommend immersing yourself in some modular arithmetic. –  anon Aug 5 '11 at 0:01
    
Another (equivalent) way of doing the trick is for the magician to subtract your number of cards from $52$, then do the sum of digits stuff, more than once if necessary. I guess the version in the video is there because the magician is not trusted to do the subtraction. –  André Nicolas Aug 5 '11 at 2:10
add comment

2 Answers

up vote 2 down vote accepted

This is a simple application of "casting out nines".

The sum of the digits of any base ten number, $n$, is equal to $n\pmod{9}$. This is because $10^k=1\pmod{9}$. This is easy to see: take any power of $10$, $10^k$ and subtract $1$; you get a string of $k$ $9$s. Any base ten number, $n$, can be written as the following weighted sum of its digits, $d_k$ $$ n = \sum_k\;d_k10^k $$ $s$, the sum of the digits of $n$, is given by $$ s=\sum_k\;d_k $$ Thus, the difference of $n$ and $s$ is $$ n-s = \sum_k\;d_k(10^k-1) $$ where each term has a factor of $10^k-1$ which is divisible by $9$. Therefore, the difference of a number and the sum of its digits is divisible by $9$. That is, $s=n\pmod{9}$. Thus, by repeatedly adding the digits of $n$ until there is only one digit left, you have found a number from $1$ to $9$ which is equal to $n\pmod{9}$.

The card trick works because the number of cards in the deck is $52=7\pmod{9}$. This means that the sum of the number of cards in all three piles must be $7=16\pmod{9}$.

If $s$, the number of cards in the dealers hand, is from $1\mathrm{\ to\ }6\pmod{9}$, then the sum of the number of cards in the other two hands will be $7-s\pmod{9}$. If $s$ is from $7\mathrm{\ to\ }9\pmod{9}$, then the sum of the number of cards in the other two hands will be $16-s\pmod{9}$.

share|improve this answer
    
There is one exception to what I said above. If $n=0$, then the sum of its digits is $0$, not $1$ to $9$. However, it is still the case that $0=0\mod{9}$. This means that you don't want to leave the dealer with $0$ cards or both of the others with $0$ cards, or the trick, as described in the video, will fail. –  robjohn Aug 5 '11 at 0:32
add comment

This is not that difficult to understand, but perhaps the idea is new to you.

You are dividing the deck into 3 parts and they add up to 52 cards. Also, note that adding the digits of a number till you are left with only one number is the same as looking at the number modulo 9. That is, considering the remainder when the number is divided by 9.

So, you start with the deck having a value of 7. (52 cards so 5+2=7). Then you have some number of cards in your hand, say 26. Then the value of your hand is 2+6=8. But you cannot take away 8 from 7 so you take away 8 from the next number that has a sum 7. That number is 16. So, 16-8=8. So, the remaining cards must have a value of 8. because then their 8 and your 8 add up to 16 which is 7.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.