# Is there $n \geq 2$ such that $1^1 + 2^2 + \dots + n^n$ is a perfect square?

Define $S_n = 1^1 + 2^2 + 3^3 + \dots + (n - 1)^{n - 1} + n^n$. It is clear that $S_1 = 1^1 = 1$ is a perfect square. However, I have found no others so far.

Question: Does there exist $n \geq 2$ such that $S_n$ is a perfect square?

I have checked via computer that there are no solutions for $2 \leq n \leq 3000$. Analysis modulo $3$ reveals that $$n \equiv 2,3,5,6,10,13 \pmod{18} \Rightarrow S_n \equiv 2 \pmod{3},$$ and hence $S_n$ is not a perfect square for these values of $n$. I imagine one could do similar analysis using other moduli, but it does not seem to eliminate many values of $n$.

I currently do not have a great reason for believing that the answer to the question is no, but I also have no idea how, aside from burning my CPU, to show that the answer could be yes. Any other ideas would be greatly appreciated.

(I even tried searching for perfect powers in general, and have so far only found $$S_3 = 2^5$$ as an example.)

Edit 1: The analysis done modulo 3 can be replicated for other moduli, and this can actually be useful if you are trying to search for solutions by computer. I make a useful conjecture:

Conjecture: The residues of $S_n$ modulo an odd prime $p$ are periodic (over consecutive integers $n$) with period $p^2(p - 1)$. Furthermore, there are exactly $p(p - 1)^2/2$ residues of $n$ modulo $p^2(p - 1)$ which imply $S_n$ to not be congruent to a quadratic residue modulo $p$.

Thus, we can identify, based on the residue of $n$ modulo $p^2(p - 1)$, whether $S_n$ is congruent to a quadratic residue modulo $p$. This is beneficial since I imagine computing $n$ mod $p^2(p - 1)$ is faster than checking whether $S_n$ is a perfect square.

With this "result" applied to only the first six odd primes $3,5,7,11,13,17$ (I have verified the conjecture is true for these), it appears we already can say that for about $96.4 \%$ of the natural numbers, $S_n$ is not a perfect square. You could probably show this rigorously via the Chinese Remainder Theorem, but whatever. (And of course, I imagine the more primes you use, the better the results, but at some point too many modulus operations becomes a burden.)

• What is the source of this problem? This related question appeared yesterday. – lulu Jun 11 '18 at 10:30
• Yes, I forgot to mention that is where this problem came from. – theyaoster Jun 11 '18 at 10:38
• Ah. Well, I don't see a useful algebraic factoring. For a particular $n$ you can look at primes $p$ such that $p-1\,|\,n$ which simplifies the sum enormously. Otherwise, it looks hard to attack. – lulu Jun 11 '18 at 10:47
• Let $p$ be any prime greater than $n$. Fermat's Little Theorem forces the $n$th partial sum to be $\equiv n(n+1)/2$ mod $p$. Only the "triangular squares" $1^2, 6^2, 35^2,...$ seem to have a chance so we need this to work for $n \in \{1, 8, 49,...\}$. – Oscar Lanzi Jun 11 '18 at 12:48
• No further perfect power upto $n=87\ 000$ – Peter Jun 11 '18 at 22:59