## Task 3 - 170913

Mr. $A$ bought several identical books in a bookstore. He would have had to pay an integer amount in marks for each of these books, which was exactly as large as the number of books he bought. However, due to his bulk purchase, he received a one-mark discount on each book.

When he wanted to pay, he found that he only had 10-mark bills with him; he had enough to cover the cost, but the total price was not a whole multiple of 10 marks. The seller could not give him change.

Mr. $B$, an acquaintance of Mr. $A$, was also in the bookstore at the same time. He had also bought some (different) identical books, and the price of each individual book was exactly as many marks as the number of books he bought. He did not receive any discount.

Since their combined bills amounted to a sum that could be paid entirely with 10-mark bills, Mr. $A$ paid the part of Mr. $B$'s bill that was still missing after Mr. $B$ had paid as much of his bill as possible with 10-mark bills.

How many marks did Mr. $A$ pay for Mr. $B$?
Assuming Mr. $A$ bought $a$ books. Then the original price of a book was $a$ marks, and after the discount, it was $(a-1)$ marks. Mr. $A$ therefore had to pay $a(a-1)$ marks.

The products of two consecutive natural numbers always end in one of the digits 0, 2, or 6, as can be seen from the following table:

| Last digit | Last digit  $a$ | Last digit  $a(a-1)$ | Last digit  $a-1$ | Last digit  $a$ | Last digit  $a(a-1)$ |
| :---: | :---: | :---: | :---: | :---: | :---: |
| 0 | 1 | 0 | 1 | 2 | 2 |
| 2 | 3 | 6 | 3 | 4 | 2 |
| 4 | 5 | 0 | 5 | 6 | 0 |
| 6 | 7 | 2 | 7 | 8 | 6 |
| 8 | 9 | 2 | 9 | 0 | 0 |

Since the amount could not be paid with 10-mark bills alone, a remainder of 2 or 6 marks was left.

Mr. $B$ had to pay a total of $b^2$ marks if he bought $b$ books. Since the amount he had to pay, together with the amount paid by Mr. $A$, resulted in a multiple of $10 \mathrm{M}$, this amount had to end in the digit 8 or 4.

However, there is no square number ending in the digit 8, but there are square numbers ending in the digit 4. Therefore, Mr. $B$ had to pay an amount whose last digit was 4. Mr. $A$ thus paid 4 marks for Mr. $B$.