Example 1. A number greater than 9 is called GOOD, if we add the product of the digits to the sum of the digits, the result is the original number. For example, 29 is GOOD since 2 + 9 + 2 × 9 = 29, but 413 isn’t GOOD since 4 + 1 + 3 + 4 × 1 × 3 ≠ 413. How many GOOD numbers are there?
Example 2. There are 1000 doors named D1, D2, D3, . . . , D1000. There are 1000 persons named P1, P2, P3, . . . , P1000. At first, all the doors are closed. P1 goes and opens all the doors. Then P2 goes and closes even-numbered doors i.e., D2, D4, D6, . . . , D1000 and leaves the odd-numbered doors i.e., D1, D3, D5, . . . , D999 as it is. Then P3 goes and changes the state of the doors (if open then closes and if closed then opens) which are multiples of 3 i.e., the doors D3, D6, . . . Then P4 goes and changes the state of the doors which are multiple of 4. In this way, 1000 persons go and change the states of the doors accordingly. At the end, how many doors will be open and how many doors will be closed?
Of course, you can find the solution just below, but it is highly recommended that you first try to solve it on your own.
Just remember the words of Paul Halmos, who says “the only way to learn mathematics is to do mathematics”.
Solution 1. We will look into the following cases:
Case 1. Let the number be of two digits. If we consider it as AB, then the number is GOOD if
A + B + A × B = 10 × A + B.
Rearranging this equation, we get A × B = 9 × A.
This implies that B = 9 and the numbers are 19, 29, 39, . . . , 99 are all GOOD.
So, there are 9 GOOD two-digit numbers.
The numbers are 19, 29, 39, 49, 59, 69, 79, 89 and 99.
Case 2. Let the number be of three digits. If we consider it as ABC, then the number is GOOD if
A + B + C + A × B × C = 100 × A + 10 × B + C.
Rearranging this equation, we get A × B × C = 99 × A + 9 × B. (1)
Note that, B and C ≤ 9, so that B × C ≤ 81.
It follows that, A × B × C ≤ 81 × A.
Also, 81 × A < 99 × A + 9 × B is evident. Therefore,
A × B × C ≤ 81 × A < 99 × A + 9 × B.
Hence, the equality in (1) is not possible. As a result, there are no GOOD three-digit numbers.
The argument can be extended to any number of digits greater than 2. Let we have an n-digit number AB…N. This number is GOOD if
A + B + ∙∙∙ + N + A × B × ∙∙∙ × N = A × 10n−1 + B × 10n−2 + ∙∙∙ + N
Or, A × B × ∙∙∙ × N = A × (10n−1 −1) + B × (10n−2 −1) + ∙∙∙ (2)
After rearranging, we get
A × (B × ∙∙∙ × N) ≤ A × 9n−1 < A × (10n−1 −1) + B × (10n−2 −1) + ∙∙∙
Hence, the equality in (2) is not possible. As a result, there are no GOOD numbers with more than two digits.
Solution 2. Let us take an example.
Let us see how many times and which persons are operating on D28.
The persons who are operating on D28 are P1, P2, P4, P7, P14, P28.
Now, 1, 2, 4, 7, 14, 28 are factors of 28.
So, any door Di is getting operated by the persons Pj where j’s are the factors of i.
In this case, we are not interested to find the factors of every number up to 1000. Rather we are interested in which doors are getting operated an odd number of times and which doors are getting operated even number of times.
In other words, which numbers have an odd number of factors and which numbers have an even number of factors.
If there are odd number of factors, then odd number of operations and the door will be open. On the other hand, if there are even number of factors then even number of operations and the door will be closed.
We have seen that every number has even number of factors except the square numbers, which have odd number of factors.
So, D1, D4, D9, D16, . . . , D961 these 31 doors will stay open and rest of the doors will stay closed.