Determine all the numbers formed by three different and non-zero digits, such that the six numbers obtained by
permuting these digits leaves the same remainder after the division by 4.
All 3 digits must have the same parity, so the odd digits can be analyzed separately from the even digits.
The mod4 value of a 3-digit number is the same as the mod4 value of the last 2 digits.
Evens: Consider flipping the last 2 digits. What pairs of even digits have the same mod4 value when reversed? 26, 48 (or 04, but zero is excluded). The 2 digits must differ by 4, so the only triplet would be {0,4,8} but zero is excluded. So there is no solution with even digits.
Odds: if both digits of a 2-digit number are odd, which ones do not have their mod4 value changed by reversing the digits? 15, 19, 37, 59 Again, the difference must be 4 (or a multiple of 4).
The only triplet which can be formed from these pairs is: {1,5,9}.
Confirmed with a short program.
('1', '5', '9')
159 3
195 3
519 3
591 3
915 3
951 3
------------
from itertools import combinations
from itertools import permutations
for comb in combinations('123456789', 3):
remainder = int(''.join(comb)) % 4
winner = True
for perm in permutations(comb):
x = int(''.join(perm))
if x % 4 != remainder:
winner = False
break
if winner:
print(comb)
for perm in permutations(comb):
x = int(''.join(perm))
print(x, x%4)
|
Posted by Larry
on 2024-05-17 13:23:55 |