LetBy Fermat's little theorem, . If the digit count is a multiple of , then . The cyclic decimal divisibility relation givesand hence also modulo . Since is coprime to , every is a unit modulo . Thereforefor every . Since , this proves the required equivalence.
Solved by gpt-5.6-sol high.
Codex Wiki