Solution (source code)

= Solution

Since $a=kp\ge2$, we have $a^p\equiv1\pmod{a^p-1}$ and $\gcd(a,a^p-1)=1$. Its <multiplicative order> therefore divides the <prime number> $p$. It cannot be one, because $0<a-1<a^p-1$. Thus \b[the order is exactly $p$].

To find the desired prime divisor, use the <cyclotomic polynomial>
$$
\Phi_p(a)=1+a+\cdots+a^{p-1}>1.
$$
Choose a <prime factor> $q$ of this integer. Since $p\mid a$, we have $\Phi_p(a)\equiv1\pmod p$, so $q\ne p$. Also $q\nmid a$. If $a\equiv1\pmod q$, then $\Phi_p(a)\equiv p\pmod q$, contradicting $q\ne p$. Consequently $a$ has <multiplicative order> $p$ in the <multiplicative group of a finite field> $\mathbb F_q^\times$. <Lagrange theorem> gives
$$
\boxed{p\mid q-1.}
$$
This $q$ divides $a^p-1$ as required. Notice that order $p$ modulo a composite integer alone would not justify selecting an arbitrary prime divisor; the <cyclotomic polynomial> selects a suitable one.

If there were only finitely many such primes $q_1,\ldots,q_r$, choose $k=q_1\cdots q_r$, with the empty product interpreted as one. Each $q_i$ divides $a=kp$ and hence does not divide $a^p-1$. The preceding argument supplies a further prime $q\equiv1\pmod p$ dividing that integer, a contradiction. \b[There are infinitely many primes in this residue class.]