5
$\begingroup$

The magician will perform some mathematical magic. He asks his guest to secretly pick any two digit number and then perform a number of operations on it.

  1. If the number is even, divide by 2, if it is odd subtract 3 and then divide by 2.
  2. Multiply by 3.
  3. Add 5.
  4. If the number has 3 digits, subtract 102.
  5. Multiply by 6.
  6. Subtract 21.
  7. Compute the sum of the digits and continue with this sum. For example if you have 41, continue computing with 5=4+1. *
  8. If the number has only a single digit, multiply by 2.
  9. Subtract 5.

At this point, the magician reveals the number the guest arrived at after step 9.

How does this trick work?

Edit: * As noted in the comments, it can happen that you have a negative number at this point. In this case just ignore the minus sign in front. So for example the sum of digits of -16 would be 7.

$\endgroup$
2
  • 1
    $\begingroup$ What do you do in step 7 if the number is negative? Treat the sum as negative? (This occurs if you begin with 64, 66, 67, or 69.) $\endgroup$ – Nick Matteo Nov 3 '20 at 21:45
  • $\begingroup$ @NickMatteo Nice catch, when setting the problem up, I didn't notice this could be negative. If you just ignore the negative sign, everything works out as expected. $\endgroup$ – quarague Nov 4 '20 at 9:15
9
$\begingroup$

The number chosen is somewhere between $10$ and $99$.

  1. After the first step, we have a number $n$ which is between $4$ and $48$.

  2. After the next two steps, we have $3n+5$ which is between $17$ and $147$.

  3. After the fourth step, we have either $3n+5$ or $3n-97$ which is less than $100$. Call this new number $m$; it is congruent to $2$ modulo $3$.

  4. After the next two steps, we have $6m-21=3(2m-7)$, which is an odd number and a multiple of $9$ since $m\equiv2\;(mod\;3)$.

  5. The digit sum of a multiple of $9$ is always a multiple of $9$, so after the next step we have either $9$ or $18$ (it can't be as high as $27$ since anything less than $999$ won't have such a big digit sum).

  6. After the 8th step, we have $18$ for sure.

So the final answer is

$13$. Unlucky!

$\endgroup$
4
  • $\begingroup$ @NickMatteo Thanks, fixed that. Yeah, it doesn't matter to the conclusion; in the early stages I was just including all the bounds I could see, not knowing exactly where this was going. $\endgroup$ – Rand al'Thor Nov 5 '20 at 8:55
  • $\begingroup$ Your step 4 might be a bit clearer if you put it in terms of n. I spent a while looking at the equation and wondering how you concluded it was a multiple of 9 before I realised that it was because m was constrained. Having it in terms of n will make it much clearer that it is a multiple of 9 since you can just take that factor out. $\endgroup$ – Chris Nov 5 '20 at 12:09
  • $\begingroup$ @Chris I can't put it directly in terms of $n$ since there are two different options for $m$ in terms of $n$, but I added an extra clause to clarify. $\endgroup$ – Rand al'Thor Nov 6 '20 at 7:45
  • $\begingroup$ I was just thinking adding something like "which is 18n+9 or 18n-603 which can be factored as 9(2n+1) or 9(2n-67)".This is much what you did in step 3 where you showed the two possible totals depending on whether you needed to subtract 102 or not. $\endgroup$ – Chris Nov 6 '20 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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