I was wondering, whether the Repdigit $77...77$ (i.e. the number all of whose digits are $7$) can be the sum of two squares for some number of digits.

With elementary methods I could show, that if this can happen, the number of digits must be a multiple of $198$. The phenomenon that occurs (for the numbers I examined) is, that every time I have enough digits to "square" a prime divisor $p$ with $p \equiv 3 \mod 4$, I get new (and even more) single prime divisors $p \equiv 3 \mod 4$.

So I suppose, that none of these numbers can be written as the sum of two squares. Does anyone have an idea of how to prove (or disprove) that?

  • 1
    $\begingroup$ This question doesn't belong here; this site is for mathematicians and their research. I'm migrating this over to Math.SE, but it seems to me there is no such representation, by consideration of prime factorizations in the Gaussian integers and the fact that 7 is a prime in that ring. I'm sure someone over at Math.SE would be happy to explain. $\endgroup$
    – Todd Trimble
    Apr 27 '14 at 17:31
  • $\begingroup$ No, impossibility does not follow just by considering the prime $7.$ For example, $777777$ is divisible by $49,$ but not by $343.$ $\endgroup$ Apr 27 '14 at 23:18
  • 3
    $\begingroup$ In fact, I would need to be convinced that it is possible to eliminate every such integer being a sum of two squares by elementary means. $\endgroup$ Apr 27 '14 at 23:39
  • 1
    $\begingroup$ @user43208 Like Geoff I do not think that considering 7 in the Gaussian integers will suffice. In fact I do think that this question is research level (this is why I originally posted it on MathOverflow) $\endgroup$
    – Martin
    Apr 29 '14 at 20:21
  • 6
    $\begingroup$ Martin, it seems that my mathematical comment was made too hastily, and I apologize for that. Let me see about rectifying the mistake (sometime in the next few hours). $\endgroup$
    – Todd Trimble
    Apr 29 '14 at 21:18

We start with the following observation. Let $p$ be prime. Suppose that $p$ divides $AB$ with even exponent. Then if $(A,B)$ is prime to $p$, then $p$ divides exactly one of $A$ or $B$, and hence it also divides $A$ and $B$ with even exponent. It follows that if $AB$ is the sum of two squares and $(A,B) = 1$, then $A$ and $B$ are the sum of two squares. Slightly more generally, we find:

Proposition: if $AB$ is the sum of two squares and $(A,B) = 1$ or $7$, then either $A$ and $B$ are the sum of two squares or $7A$ and $7B$ are the sum of two squares.

Now let $\displaystyle{A_n:=777 \ldots 7777 = \frac{7}{9} \cdot (10^n - 1)}$.

If $A_n$ is the sum of two squares, then so is $B_n = 9 \cdot A_n = 7(10^n - 1)$.

Lemma: The smallest integer $n$ such that $B_n$ is the sum of two squares is odd.

Proof: By observation, the smallest such $n$ is $> 2$. Assume that $n = 2m$ with $m > 1$. We shall obtain a contradiction. We write

$$B_{n} = B_{2m} = 7(10^{2m} - 1) = 7(10^{m} - 1)(10^{m} + 1) = B_{m} (10^m +1).$$

Now $(10^m - 1,10^m +1) = 1$, so $(B_m,10^m +1) = 1$ or $7$. It follows from the proposition that $B_m$ or $7 B_m$ is the sum of two squares. Since $m > 1$, it follows that $7 B_m \equiv 3 \mod 4$ is not the sum of two squares, and so $B_m$ is the sum of two squares. This contradicts the minimality of $n$. $\square$

Hence the smallest $n$ such that $B_n$ is the sum of two squares is odd. However, this contradicts the fact (which you already observed) that if $n \not\equiv 0 \mod 6$ then $B_n$ is exactly divisible by $7$ and so is not the sum of two squares. Hence $A_n$ can never be the sum of two squares.

  • 5
    $\begingroup$ @Troglodyte I am excising the final portion of your answer, which is offensive. $\endgroup$
    – Todd Trimble
    Apr 30 '14 at 2:01
  • 4
    $\begingroup$ Nice proof. The observation on Emerton posting on MSE rather than here is also interesting. Certainly a pity that he doesn't post on MO anymore -- his answers here and on MSE are uniformly excellent. $\endgroup$
    – Lucia
    Apr 30 '14 at 2:43

I like Troglodyte's answer, which I find surprising. I think it proves something rather more general, which I would like to record, though I am sure Troglodyte knows it. If $p \equiv 3$ (mod $4$) is a prime, and $a$ is an even integer which is a quadratic non-residue (mod $p$), then either $a \equiv -1$ (mod $p$), or else $p(a^{n}-1)$ is not a sum of two squares for any positive integer $n.$

The proof is more or less the same, I just labour a few details. Assume that $a \not \equiv -1$ (mod $p$). Then (if there is any such integer), the least positive integer $n$ such that $p(a^{n}-1)$ is a sum of two squares must be even, as $a$ is a quadratic non-residue (mod $p$) and $p(a^{n}-1)$ must be divisible by $p^{2}$ as $p \equiv 3$ (mod $4$). Write $n = 2m.$ Then $m >1$ as $a \not \equiv \pm 1$ (mod $p$) by hypothesis. Now $p(a^{m}-1)$ is not a sum of two squares by the minimality of $n.$ However, $a^{m} -1 \equiv 3$ (mod $4$), so is not a sum of two squares either. Now $(a^{m}-1)p(a^{m}+1)$ is a sum of two squares. Hence $a^{m}-1$ can't be coprime to $p(a^{m}+1).$ Since $a^{m}-1$ is coprime to $a^{m}+1,$ we see that $a^{m}-1$ is divisible by $p.$ Now $\frac{a^{m}-1}{p}(a^{m}+1)$ is a product of two coprime integers and is a sum of two squares. Hence $\frac{a^{m}-1}{p}$ is a sum of two squares, and so is $p(a^{m}-1),$ a contradiction.


This is not an answer, but just an observation, which Martin had probably in mind. By Fermat we know that $n=x^2+y^2$ is the sum of two squares iff the primes $p$ dividing $n$ with $p\equiv 3$ mod $4$ occur with even exponent. Suppose that $n=777\cdots 7$ has $k$ digits, and is the sum of two squares, $n=x^2+y^2$.
Now we just study the first primes $p\equiv 3$ mod $4$ which possibly divide $n$. The prime $7$ is exceptional, because $7\mid n$ without any assumtion. We have $$ 6\mid k \Rightarrow 7^2\mid n,\quad 7\cdot 6\mid k \Rightarrow 7^3\mid n, \quad 7^2\cdot 6\mid k \Rightarrow 7^4\mid n,\ldots $$

$$ 2\mid k \Rightarrow 11 \mid n,\quad 2\cdot 11\mid k\Rightarrow 11^2\mid n,\quad 2\cdot 11^2\mid k \Rightarrow 11^3\mid n,\ldots $$ There is enough data for the factorization of $n$ here, multiplying $111\cdots 1$ there with $7$. If we do this with several such primes, we can say at least something on $k$, the number of digits of $n$:

If $6\nmid k$, then $7^1$ is the exact power of $7$ dividing $n$; i.e., $7^1\mid\mid n$. This contradicts Fermat's result. Hence we can conclude that $6\mid k$. It implies $3\mid k$, so that $9\mid k$, because otherwise $3^1\mid\mid n$, which is impossible. Also $2\mid k$, so that $11\mid n$. This implies $198=11\cdot2\cdot 3^2\mid k$, because otherwise $11^1\mid \mid n$, which is impossible. This is what Martin already had. We may continue now that in particular $33\mid k$, i.e., $67\mid n$. Since if not $3\cdot 11\cdot 67\mid k$ then $67^1\mid \mid n$, we arrive at $13266=2\cdot 3^2\cdot 11\cdot 67\mid k$, etc. I have no idea whether this will continue, or whether we will finally find a possible $k$.

  • $\begingroup$ Yes, that was what I was thinking. I am sure that this will continue in that way, but of course that is no proof $\endgroup$
    – Martin
    Apr 28 '14 at 12:54
  • $\begingroup$ Your non-answer (?) will sound much more impressive if you'd change Fermat with Jupiter: See end of first row. $\endgroup$
    – Lucian
    Apr 28 '14 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.