A "mathemagician" performs magic with green, yellow, blue, and red cards, numbered from 1 to 13 for each color. He shuffles the cards and says to a child: "Without me seeing, choose a card, calculate double the number on the card, add 3, and multiply the result by 5. Then

add 1, if the card is green;

add 2, if the card is yellow;

add 3, if the card is blue;

add 4, if the card is red.

Tell me the final result, and I will tell you the color and the number of the card you chose."

a) Joãozinho chose the red card with the number 3. What number should he tell the mathemagician?
b) Mariazinha said "seventy-six" to the mathemagician. What is the number and the color of the card she chose?

c) After choosing a card, Pedrinho said "sixty-one" and the mathemagician replied "You made a mistake in your calculation." Explain how the mathemagician could have known this.
Solution

a) To know the number that Joãozinho should tell the mathemagician, he must do four calculations:

$1^{st}$ calculation: multiply the number on the chosen card by 2;

$2^{nd}$ calculation: add 3 to the result of the first calculation;

$3^{rd}$ calculation: multiply by 5 the result of the second calculation;

$4^{th}$ calculation: add 1, 2, 3, or 4 to the result of the third calculation, depending on the color of the chosen card.

Since the number on the card chosen by Joãozinho was 3, the result of the first calculation is $3 \times 2=6$; the result of the second calculation is $6+3=9$ and the third is $9 \times 5=45$. Finally, since the color of the card chosen by Joãozinho is red, the result of the fourth and final calculation is $45+4=49$. So Joãozinho should say "forty-nine" to the mathemagician.

b) $1^{st}$ solution: Let's analyze what happens to the number on a card when we perform the indicated operations. Regardless of this number, after the third calculation, we obtain a multiple of 5, that is, a number whose unit digit is 0 or 5. We then conclude that, if all the calculations are correct, the unit digit of the number said to the mathemagician is:

- 1 or 6, if the chosen card is green;
- 2 or 7, if the chosen card is yellow;
- 3 or 8, if the chosen card is blue;
- 4 or 9, if the chosen card is red.

Thus, if Mariazinha said 76 to the mathemagician, her card was green and the result of the third calculation she performed was $76-1=75$; the result of the second calculation was $75 \div 5=15$; the result of the first calculation was $15-3=12$ and the number on the card chosen by Mariazinha was $12 \div 2=6$. Checking: $(2 \times 6+3) \times 5+1=76$.

$2^{nd}$ solution: This solution does not differ essentially from the previous one, but it is more precise and allows for an immediate solution to item $c$). As before, let's analyze what happens to the number on a card when we perform the indicated operations. Regardless of this number, when we multiply by 2, we get an even number; when we add 3 to the result, we get an odd number (this is the detail in which this solution differs from the previous one). When we multiply by 5, we get a number whose unit digit is 5. We then conclude that, if all the calculations are correct, the last digit of the number said to the mathemagician is

- 6, if the chosen card is green;
- 7, if the chosen card is yellow;
- 8, if the chosen card is blue;
- 9, if the chosen card is red.

The rest of this solution proceeds as the previous one.

$3^{rd}$ solution: Let $x$ be the number on a card; then the number said to the mathemagician is $5(2 x+3)+y=10 x+15+y$, where $y$ is an integer from 1 to 4 corresponding to the color of the card. Here we have $10+15+y=76$, that is, $10 x+y=61$. Since the unit digit of $10 x$ is 0, we see that $y$ can only be $1$; thus $10 x=60$ and $x=6$, so we conclude that the chosen card was 6 green.

c) $1^{st}$ solution: (according to the $1^{st}$ solution of item b)): When Pedrinho said 61 to the mathemagician, he thought as follows: if Pedrinho's calculations are correct, the card must be green (since the unit digit of 61 is 1) and after the third calculation, the number obtained was $61-1=60$, after the second calculation the number obtained was $60 \div 5=12$, after the first calculation the number obtained was $12-3=9$ and then the number on the card must be $9 \div 2=4.5$, which cannot happen since the numbers on the cards are integers. Therefore, Pedrinho must have made a mistake in some calculation.

$2^{nd}$ solution: (according to the $2^{nd}$ solution of item $b$)): Saying a number to the mathemagician whose unit digit is different from 6, 7, 8, or 9 indicates that there was some calculation error.