Magic Trick to Read your Mind I am a student in High School. My math professor made a magic trick the other day in my class and he read our minds. I knew a similar trick which was based on mathematics, that's why I am asking here.
He told as to choose a random positive number and keep it secret in our mind. Then he told us to multiply or subtract any number we want and after a few times, he could guess our number.
The similar "magic trick" I knew, asked for a number like before, but somewhere in the middle asked to subtract by the initial number we have in our minds. This time was different.
Edit:
The teacher guess the final number only. Not the number he had in our mind. Here are a few of his orders as I have them on my notebook.
Choose a number -> add any number you want -> multiply by any number -> sum to one digit -> multiply again by any number -> multiply by 3 -> multiply by 3 -> sum to one digit -> I have to add 1 and the student next to me to subtract by 4 -> then he guess that I have 10 and it is the double of the student next to me who had 5.
Choose a number -> multiply by any number -> add any number -> sum to one digit -> multiply by 3 -> multiply by 6 -> divide by 2 -> sum to one digit -> multiply by 2 -> add the number 2 -> he guess that I have the number 20.
 A: This problem reminds me my own math teacher from several years before.
Let's say that the number you have in your mind is "x".
I can start with "multiply with any number you want" and you have now 2x for example.
Then again, "multiply with any number you want" and you have now 5(2x) for example.
Now, add any number and you are on [5(2x)]+8, if you chose the 8.
Now, sum all the digits until you have one only digit.
Until now, I don't have a clue about your number. Anyone cannot have a clue.
But, add one number and you have for instance y+3.
Now, multiply by 9 and you have (y+3)*9. You saw that? It was the first time I asked you to multiply by a specific number.
Now, sum all the digits until you have one only digit.
And here you are. Now your number is 9. If you multiply every positive number with 9 and then sum its digits, you will always end up with 9 again.
My teacher used to add a few more numbers to avoid the 9 as a results each time.
For instance, add the number 4. And then, he said, the number in your mind is the 13.
A: The crucial part in this trick is summing the digits so there's only one digit left, this is the same as taking the remainder when dividing by 9. This works because
$$10\equiv 1 \mod 9$$
and thus, for example
$$123 \equiv 1\cdot 10^2 + 2\cdot 10 + 3 \equiv 1\cdot 1^2 + 2\cdot 1+ 3 \equiv 1+2+3 \equiv 6 \mod 9.$$
In both tricks, you multiply by a multiple of $9$ at some point: In the first you multiply by $3$ two times and in the second you multiply by $3$ and $6$ and divide by $2$, which is effectively multiplying by $9$.
After that, the number in your head will be congruent to $0$ modulo $9$. The only one-digit numbers congruent $0$ modulo $9$ are of course $0$ and $9$, but when summing digits you can't end up with $0$, so you will get $9$ for sure. Now your teacher just builds up any number he likes and blows your mind when he magically knows it!
A: In both examples he is using the trick that the digits sum to 9 in any number that is a multiple of 9 (by "digits sum to 9" I mean if you keep going til there's only one digit left). The rest is just window dressing to hide the simplicity of the trick.
So in the first example you will see "multiply by 3, multiply by 3, sum to one digit". It doesn't matter what you did before this point - he now knows your answer is 9. Then he got you and the other student to add/subtract different numbers (to hide the fact you both had 9). All he had to do was work out 9+1 and 9-4. 
In the second example you will see "multiply by 3, multiply by 6, divide by 2, sum to one digit". 3x6/2 = 9 so again you are multiplying by 9 and summing to one digit. Again, he now knows you have 9 and just needs to do 9x2+2=20 in the subsequent instructions to know your number is 20.
Notice that as soon as he's got you to sum the digits, he doesn't get you to add/subtract/multiply/divide "by any number" any more? That's because that's the point at which he knows your number. Any calculations before that point are meaningless, so you might as well do "any number", whereas if you did "any number" after the critical "multiply by 9 and sum to one digit" bit he would lose the information he has on your number.
Why this works
Basically this works because 9, 99, 999 etc are all multiples of 9 which means that:
1000 ≡ 100 ≡ 10 ≡ 1 mod 9
Since you are a high school student I am not sure if you've come across modulo notation so I will try and explain in layman's terms (Christoph gives a nice formal answer for those that are looking for one).
This line:
1000 ≡ 100 ≡ 10 ≡ 1 mod 9
means that for all those numbers (and, indeed, any power of 10, not just the ones I've listed), when you divide by 9 you get a remainder of 1. So if you divide 10n by 9 you get a remainder of n (e.g. 50/9 gives remainder 5) - a remainder of one for each 10 that you had (since 10-9=1).
Clearly, in order for the whole number to be divisible by 9, you need a total remainder that is divisible by 9. So 54 works because the 50 gives a remainder of 5 and the 4 gives a remainder of 4, and 5+4=9. 
This is really a special case of the way it works with any number. So, with 8, you have a remainder of 2 for every 10 and a remainder of 4 for every 100. So if you multiplied the 100s digit by 4, the 10s digit by 2 and the 1s digit by 1 you would get a multiple of 8 (and 8 itself if you kept going to one digit). 8 divides 1000 so you wouldn't need to do any other calculations even if you had bigger numbers. 9 is just special because the remainder is 1 in each case, so you can simply "sum to one digit" without multiplying different digits by different things.
If you wanted to impress your teacher you could read his mind without multiplying by 9 by making the adjustments for multiplying by another number (say, 8) as above :)
