This problem is inspired by a video A delightful logic puzzle from the Stanford Competitive Exam (1947). Here is the illustration of the algorithm devised by me to solve the problems of similar nature.
Problem: Suppose there is a number 1A6B3 which is completely divisible by 27, where A and B are digits. Find all possible pairs (A, B).
Answer: (2, 6), 5, 3), (8, 0) and (9, 8)
Solution:
If we take A = 0 and B = 0, then the number = 10603
Suppose X%Y represents the remainder when X is divided by Y.
Hence, 10603%27 = 19
Also Since, 1000%27 = 1
Hence, If we will increase the number by 1000 then the remainder will increase by 1.
If we increase 10603 by 1000, then new number = 11603. Please note here we are taking A = 1.
Hence,
When A = 0, 10603%27 = 19
When A = 1, 11603%27 = 19 + 1 = 20
When A = 2, 12603%27 = 20 + 1 = 21*
When A = 3, 13603%27 = 21 + 1 = 22
When A = 4, 14603%27 = 22 + 1 = 23
When A = 5, 15603%27 = 23 + 1 = 24*
When A = 6, 16603%27 = 24 + 1 = 25
When A = 7, 17603%27 = 25 + 1 = 26
When A = 8, 18603%27 = (26 + 1)%27 = 27%27 = 0*
When A = 9, 19603%27 = 0 + 1 = 1*
In case of A = 8, since remainder is 0, hence (A, B) = (8, 0) is the surest answer!
All possible two digit multiples of 27: 27, 54 and 81. Unit digits of these multiples are 1, 4 and 7.
The unit digits of remainders 21(when A = 2), 24(when A = 5) and 1(when A = 9) matches with that of multiples of 27(81, 54 and again 81).
Now let us explore these three cases one by one.
When A = 2, 81 - 21 = 60, hence B = 6(Tenth digit of 60). Hence, (A, B) = (2, 6)
When A = 5, 54 - 24 = 30, hence B = 3(Tenth digit of 30). Hence, (A, B) = (5, 3)
When A = 9, 81 - 1= 80, hence B = 8(Tenth digit of 80). Hence, (A, B) = (9, 8)
~ Jayram