TITLE: Find all $n\in\mathbb{Z}^+$ satisfying : $n\mid(2^{\varphi(n)}+3^{\varphi(n)}+\cdots +n^{\varphi(n)}).$
QUESTION [6 upvotes]: Find all $n\in\mathbb{Z}^+$ satisfying : 
(i) $n$ has at most $4$ prime divisors .
(ii) $n\mid(2^{\varphi(n)}+3^{\varphi(n)}+\cdots +n^{\varphi(n)}),$ where $\varphi(n)$ is the Euler function.

REPLY [10 votes]: Let $n = p^k\cdot m$ with $k \geqslant 1$ and $p \nmid m$. Since $k \leqslant 2^{k-1} \leqslant (p-1)p^{k-1} = \varphi(p^k)$, and $\varphi(p^k) \mid \varphi(n)$, we have
$$a^{\varphi(n)} \equiv \begin{cases} 0 &, p \mid a\\1 &, p \nmid a \end{cases} \pmod{p},$$
and therefore
$$\sum_{a=2}^n a^{\varphi(n)} \equiv -1+ \sum_{a=1}^n a^{\varphi(n)} \equiv -1 + m\sum_{a=1}^{p^k} a^{\varphi(n)} \equiv -1 + m\cdot\varphi(p^k) \pmod{p}.$$
If $k > 1$, then $p\mid \varphi(p^k)$, and the sum is $\equiv -1 \pmod{p}$, hence an $n$ with $(ii)$ must be squarefree. Then the condition is that $m(p-1) \equiv 1 \pmod{p}$, or
$$\frac{n}{p} \equiv -1 \pmod{p} \iff n+p \equiv 0 \pmod{p^2}$$
for all $p \mid n$. Let $n = \prod_{i=1}^r p_i$, with $p_1 < p_2 < \dotsc < p_r$. Then
$$n^2 \mid \prod_{i=1}^r(p_i + n) = n\left(1 + \sum_{i=1}^r\frac{n}{p_i}\right) + n^2\cdot  M,$$
and hence
$$\sum_{i=1}^r\frac{1}{p_i} + \frac{1}{n} \in \mathbb{N}.$$
So let's consider the number of prime divisors of $n$ in sequence:

$r = 0$: $n = 1$ the sum is empty, hence $0$.
$r = 1$: That means we must have $\frac{2}{p} \in \mathbb{N} \Rightarrow p = 2$, and indeed $2^{\varphi(2)} = 2 \equiv 0 \pmod{2}$.
$r = 2$: We must have $\frac{1}{p}+\frac{1}{q} + \frac{1}{pq} \in \mathbb{N}$, and since $\frac12 + \frac13 +\frac16 = 1$, $n = 6$ is the only possibility for a product of two primes. Indeed $\varphi(6) = 2$, and $2^2+3^2+4^2+5^2+6^2 = 90 \equiv 0 \pmod{6}$.
$r = 3$: We must have $\frac1p + \frac1q + \frac1r + \frac{1}{pqr} \in \mathbb{N}$. Since $\frac12+\frac13+\frac15+\frac{1}{30} = \frac{32}{30} < 2$, the sum of the reciprocals must be $1$, and the only solution for that is $p=2,q=3,r=7$, and $n = 42$. (I skip the verification from here on.)
$r = 4$: Since $\frac12 + \frac13 + \frac15 + \frac17 + \frac{1}{210} = \frac{248}{210} < 2$, the sum must again be $1$. Since $\frac13+\frac15 +\frac17 +\frac{1}{11} + \frac{1}{1155} = \frac{887}{1155} < 1$, the smallest prime factor must be $2$. $\frac12 + \frac15+\frac17 + \frac{1}{11} + \frac{1}{770} = \frac{727}{770} < 1$, so the second smallest prime factor must be $3$. $\frac12 + \frac13 + \frac15 > 1$, so the third prime factor must be larger than $5$. We find $\frac{1}{2} + \frac{1}{3} + \frac{1}{7} + \frac{1}{43} + \frac{1}{1806} = 1$, so $1806$ is our next solution. For the third prime factor being $11$, there is no solution (last prime factor $13$ gives a sum $> 1$, last prime factor $17$ a too small sum), and with the third prime factor $\geqslant 13$, the sum is always smaller than $1$.

So the complete list of positive integers $n$ with at most four prime factors and
$$\sum_{a=2}^n a^{\varphi(n)} \equiv 0 \pmod{n}$$
is $\{1,\,2,\,6,\,42,\,1806\}$.