Since $999 = 27 \times 37$, multiplying both sides by $999$ yields:
$$100a + 10b + c = 37(a + b + c)$$
Expanding and collecting terms:
$$100a + 10b + c = 37a + 37b + 37c$$
$$63a = 27b + 36c$$
Dividing both sides by $9$ gives a clean linear Diophantine equation:
$$7a = 3b + 4c$$
where $a, b, c \in \{1, 2, 3, 4, 5, 6, 7, 8, 9\}$ are nonzero digits.
Finding the Solutions with Prolog
Notice that if $a = b = c$, then $7a = 3a + 4a = 7a$ holds automatically for all $9$ repeating numbers: $111, 222, \dots, 999$.
Are there any other solutions where the digits are not all equal?
Let's let Prolog search all digit combinations and find every single solution!
abc_number(A, B, C, N) :- digit(A), digit(B), digit(C),% Diophantine equation 7*a = 3*b + 4*c: Replace ???? with 4
7 * A =:= 3 * B + ???? * C,N is 100 * A + 10 * B + C.
Move the mouse over a dotted box for more information.
Prolog generates all candidate digit triples, applies the arithmetic relation, and enumerates all 13 valid three-digit integers.
Now you try.
Replace ???? with 4 and click Run to find all 13 valid repeating decimal integers. Then check Example 1 to test each fraction verification directly, or Example 2 to find which solutions have distinct digits!
Type your code here:
See your results here:
The code has ???? for the coefficient of C. Replace ???? with 4 and click Run to find all 13 repeating decimal integers!
Prolog outputs:
Numbers = [111, 222, 333, 444, 481, 518, 555, 592, 629, 666, 777, 888, 999] Count = 13
Notice the four non-trivial solutions where digits differ:
• 481 ($7 \times 4 = 28$, $3 \times 8 + 4 \times 1 = 28$)
• 518 ($7 \times 5 = 35$, $3 \times 1 + 4 \times 8 = 35$)
• 592 ($7 \times 5 = 35$, $3 \times 9 + 4 \times 2 = 35$)
• 629 ($7 \times 6 = 42$, $3 \times 2 + 4 \times 9 = 42$)
Together with the 9 numbers having $a = b = c$, this gives exactly 13 solutions, matching option (D) 13.
Share your code
Show a friend, family member, or teacher what you've done!