# To what divisors $a$ of $n$ can Euler's Theorem multiplied by $a$ be generalized, i.e. when is $a^{\phi(n)+1}\equiv a \pmod n$?

Euler’s Theorem
$$a^{\phi(n)}\equiv 1\pmod n,$$
which is valid only iff $a$ and $n$ are coprime, can be “generalized” a bit to
$$a^{\phi(n)+1}\equiv a\pmod n, (*)$$
where some zero-divisors of $n$ are also admissible for $a$, e.g.
$$2^4\equiv 2\pmod{10},$$
while what I would like to call zero-roots$\dagger$ of $n$ fail:
$$6^4\equiv 0\pmod{12}$$

But apart from these, does the generalization $(*)$ hold for all non-zero-roots of $n$?

$\dagger$ $a$ is a zero-root of $n$ $\Leftrightarrow$ $\exists k:a^k\equiv0\pmod n$ – this is the case iff all prime factors of $a$ and $n$ are the same

#### Solutions Collecting From Web of "To what divisors $a$ of $n$ can Euler's Theorem multiplied by $a$ be generalized, i.e. when is $a^{\phi(n)+1}\equiv a \pmod n$?"

The congruence

$$a^{\varphi(n)+1} \equiv a \pmod{n},$$

or, for that matter,

$$a^{\lambda(n)+1} \equiv a \pmod{n},$$

holds if and only if for all primes $p$ dividing $n$ we have $p \nmid a$ or $v_p(a) \geqslant v_p(n)$ (where $v_p(k)$ is the multiplicity of $p$ in the prime factorisation of $k$, so $p^{v_p(k)} \mid k$, but $p^{v_p(k)+1} \nmid k$).

To see that, consider a prime $p$ dividing $n$, and let $k = v_p(n)$. Then $\varphi(p^k) = (p-1)p^{k-1}$ divides $\lambda(n)$ and a fortiori $\varphi(n)$. Now let $a$ arbitrary. If $p \nmid a$, then $a^{\lambda(n)} \equiv a^{\varphi(n)} \equiv 1 \pmod{p^k}$, and $a^{\lambda(n)+1} \equiv a^{\varphi(n)+1} \equiv a \pmod{p^k}$. And if $p\mid a$, then

$$v_p(a^{\lambda(n)}) \stackrel{\varphi(p^k)\mid\lambda(n)}\geqslant v_p(a^{\varphi(p^k)}) \stackrel{p\mid a}\geqslant \varphi(p^k) = p^{k-1}(p-1) \geqslant p^{k-1} \geqslant k,$$

so $a^{\lambda(n)} \equiv 0 \pmod{p^k}$, and a fortiori $a^{\lambda(n)+1} \equiv 0 \pmod{p^k}$ and $a^{\varphi(n)+1}\equiv 0 \pmod{p^k}$. So if $p \mid a$, we have $a^{\lambda(n)+1} \equiv a \pmod{p^k} \iff a \equiv 0 \pmod{p^k}$ (and ditto for $\varphi(n)$).

Since $a^e \equiv a \pmod{n}$ if and only if $a^e \equiv a \pmod{p^{v_p(n)}}$ for all primes dividing $n$ (that last condition is not necessary, if $p \nmid n$, we have $a^e \equiv a \pmod{p^0}$ regardless), the result follows.

It holds at least for squarefree $n$ (which explains your mod 12 exception). This is already valid for the Carmichael function $\lambda(n)$, see http://en.wikipedia.org/wiki/Carmichael_function#Exponential_cycle_length

Another way:

\begin{align} a^{\phi(n)+1} &\equiv a \pmod n \quad(*) \\\Leftrightarrow a^{\phi(n)} &\equiv 1 \pmod{n/\gcd(n,a)} \end{align}

If $a$ and $n$ are coprime (i.e. $\gcd(n,a)=1$), this is simply Euler’s Theorem and therefore true. Otherwise, since
$$\phi(a\cdot b) = \phi(a)\phi(b)\frac{\gcd(a,b)}{\phi(\gcd(a,b))},$$

let $g:=\gcd(n,a)$ and $m:=n/g$ to obtain

\begin{align} \phi(n) &= \phi(m\cdot g) \\ &= \phi(m)\cdot\underbrace{\frac{\phi(g)\gcd(m,g)}{\phi(\gcd(m,g))}}_{=:k} \end{align}

and therefore
$$(*)\Leftrightarrow \left(a^k\right)^{\phi(m)} \equiv 1\pmod m$$
which is again Euler’s theorem that holds iff $a^k$ and $m$ are coprime where $k=\phi(n)/\phi(m)$ and $m=n/\gcd(n,a)$.

I’ll try to correlate this to Daniel Fischer’s requirements later on…