Let be the number of all -digit natural numbers each consisting only of the digits (but not necessarily all of them) such that the sum of no two neighboring digits equals .
Determine whether and are divisible by .
(I. Kozlov)
Belarus — Selection and Training Session
Solution
Let , , , be the quantities of the numbers satisfying the given condition which end by the digits , , , respectively. Then . By condition,
Summing all the equalities, we get
Note that modulo we have , , , , , , , , , . Now we see that residues of the numbers modulo repeat periodically with period . So, iff or , whence , .
Want a route through all this instead of an archive? The track
puts 2,604 problems in a working order, from Junior Challenge level to the IMO shortlist.