$n$ such that $ n^2 \mid \varphi(n)^{\varphi(n)} - 1 $. Can $n$ be a prime number $n>2$ or a Carmichael number?

$n$ can't be a prime number $> 2$ because in the binomial expansion of
$(p-1)^{(p-1)} ~-~ 1$,

$p^2$ must divide all but the last term, and can not divide the last term, which is $\pm \binom{p-1}{p-2}p^1.$


Partial answer :

$n$ cannot be an odd prime.

Proof :

Let $p$ be an odd prime and denote $m:=p-1$. Then we have

$$m^m-1=\prod_{d\mid m} \Phi_d(m)$$

  • We have $\Phi_1(m)=m-1=p-2$ , which is not divisible by $p$
  • We have $\Phi_2(m)=m+1=p$

It remains to show that for $d>2$, $\Phi_d(m)$ cannot be divisible by $p$. First note $$\Phi_d(m)\equiv \Phi_{d}(-1)\mod p$$

Let $r$ be the radical of $d$ (product of the distinct prime factors of $d$). Using the well-known formula $\Phi_d(b)=\Phi_r(b^{d/r})$ , applied for $-1$ , we get $$\Phi_d(-1)=\Phi_r(\pm 1)$$ depending on the parity of $\frac{d}{r}$.

In the case $\Phi_d(-1)=\Phi_r(1)$ we have $\Phi_d(-1)=1$ or a prime factor of $r$ and hence of $d$.

So, let us assume $\Phi_d(-1)=\Phi_r(-1)$. We have $3$ cases :

  • $r=2$ , then $\frac{d}{r}$ is even, hence $\Phi_d(-1)=\Phi_r(1)=2$
  • $r$ even and greater than $2$. Then, $\Phi_r(-1)=\Phi_{r/2}(1)$ and $\frac{r}{2}>1$, so $\Phi_r(1)$ is either $1$ or a prime factor of $r$ and hence of $d$
  • $r$ odd. Then $\Phi_r(-1)=\Phi_{2r}(1)=1$

In none of the cases $p$ divides $\Phi_d(-1)$, which completes the proof.