# Number Theory Class v2

Inspired from: Number Theory Class

Our magician was unhappy because his magic was revealed so fast! so he made another magic and gave a calculator to an audience and said:

• Pick any number,
• Multiply it with 23,
• Take the sum of its digits, let's call it A,
• Multiply the number you picked again with 67,
• Take the sum of its digits again, let's call it B,
• Take the difference of these two numbers as A-B, tell me the result!

The audience member said

$-11$.

Magician said

Good, now remove any non-zero digit from your number and tell me the rest, and tell me the rest of digits in any order.

The audience member responded

$5$ and $2$.

And the magician announced in an instant,

The number you have removed was $9$.

The magician is right! How?

We use the following deep fact:

the sum of digits of a positive integer is congruent to the number itself modulo $9$.

Now let the initial number be $x$. Then

$A\equiv 23x\equiv 5x\pmod{9}$.

Also, we have

$B\equiv 67x\equiv 4x\pmod{9}.$

Therefore

$A-B\equiv x\pmod{9}$. This gives the magician the value of sum of digits of $x\pmod9$, so if he gets all but one digits of $x$, he can back-calculate the rest. For example, in the given case, if the remaining digit was $c$, then the magician could reckon that $5+2+c\equiv -11\pmod{9}\implies c\equiv-18\equiv 9\pmod{9}$, and this uniquely determines $c$ since $c$ is non-zero.