Solution (source code)

= Solution

Let
$$
l=\operatorname{ord}_p(10).
$$
By Fermat's little theorem, $l\mid p-1$. If the digit count $L$ is a multiple of $l$, then $10^L\equiv1\pmod p$. The <cyclic decimal divisibility> relation gives
$$
c_j(n)\equiv10^jn\pmod{10^L-1},
$$
and hence also modulo $p$. Since $p>7$ is coprime to $10$, every $10^j$ is a unit modulo $p$. Therefore
$$
p\mid c_j(n)\quad\Longleftrightarrow\quad p\mid n
$$
for every $j$. Since $c_0(n)=n$, this proves the required equivalence.