MathLabs

Problem 6

We call a positive integer alternating if every two consecutive digits in its decimal representation are of different parity. Find all positive integers nn which have an alternating multiple.
Step 5 of 5: Splice head and tail to finish all three families
In plain words

Splice head and tail to finish all three families

10kf ⁣(−10−kg(k) mod m)+g(k),10kf ⁣(−10−kh(k) mod m)+h(k)10^k f\!\left(-10^{-k}g(k)\bmod m\right)+g(k),\quad 10^k f\!\left(-10^{-k}h(k)\bmod m\right)+h(k)
Detailed analysis

Use the even alternating head f(b)f(b) from Step 3. For the first family concatenate it with g(k)g(k); for the other two concatenate it with h(k)h(k). The chosen residue makes each concatenation divisible by mm, while the tail supplies the required factor of 22 or 55. Because the head ends in an even digit and each tail has even length and odd leading digit, the parity alternation is preserved across the join. Since nn divides one of these constructed numbers, every 20midn20 mid n has an alternating multiple.