On 5-adic representation of square root of -1

Solution 1:

The result you hinted at is true, and follows from some facts about gaussian integers and recurrent sequences. Indeed we have:

Lemma: For any $C>0$, it is true for sufficiently large $m$ (deppending on $C$) that if $5^m$ divides $n^2+1$, then $n^2+1 > C 5^m$.

This lemma for say $C = 16 \cdot 5$ implies your result for the expansion having a non-zero digit between $l+1$ and $2l-1$ (without any non-zero digit, the truncation up to $2l-1$ would give $n < 4 \cdot 5^l$ (so $n^2+1 \le 16 \cdot 5 \cdot 5^{2l-1}$) for which $5^{2l-1}$ divides $n^2+1$, contradictng the lemma. In fact it is easy to see the lemma is equivalent to showing that for any $c$ the expansion has a non-zero digit between $n$ and $2n-c$ for large $n$.

Proof of lemma: if $5^m$ has prime factorization $(2+i)^m(2-i)^m$ in gaussian integers, and if it divides $n^2+1=(n+i)(n-i)$, then $(2+i)^m$ must divide one factor and $(2-i)^m$ the other (notice that $gcd(n+i,n-i)$ divides $2i$).

So say $\tau \cdot (2+i)^m = n+i$ where $\tau$ is a gaussian integer. Then $n^2+1 = N(\tau) \cdot 5^m$ (taking norms). Because there are only finitely many gaussian integers $\tau$ with $N(\tau) \le C$, it is enough to show that for each $\tau$, $\tau (2+i)^m = n+i$ has finitely many integer solutions. But if for some $m$ that is a solution, taking imaginary parts of both sides we get then $\tau (2+i)^m -\overline{\tau} (2-i)^m = 2i$.

But $a_m = \tau (2+i)^m -\overline{\tau} (2-i)^m - 2i$ is a linear recurrent sequence of degree 3, and these have finitely many zeroes from something such as Skolem–Mahler–Lech Theorem. So we are done with proving the lemma. Maybe there is something more specific that can be done for this case that give better bounds, since all of this is very ineffective.