Property of 111,111

Whilst playing on my calculator, I noticed the following pattern.

$1^2-0^2=1$

$6^2-5^2=11$

${20}^2-{17}^2=111$

${56}^2-{45}^2=1{,}111$

${156}^2-{115}^2=11{,}111$

To me, this is where it gets interesting:

$344^2-85^2=556^2-445^2=356^2-125^2=111{,}111.$

My question: Is $111{,}111$ the first number with only $1$s as digits that can be represented as a difference of $2$ squares in $3$ different ways? Or, can $1,11,111,1111\,\mathrm{or}\,11111$ be written as $u^2-v^2=w^2-x^2=y^2-z^2$, where $u,v,w,x,y,z$ are all unique?

I lack the knowledge to write a computer program that would check possible solutions for me. Can anyone either prove that the previous numbers can't be written as I've stated or find a counterexample?

• These numbers are called Repunit numbers.
– hola
Nov 15, 2017 at 12:49

4 Answers

Let $a$ be an odd number with $d$ divisors (so for a prime like $a=11$ we have $d=2$ and for $a=111=3\cdot 37$ we have $d=4$ and so on). Then there are $d$ ways to write $a=u\cdot v$ with $u,v\in\Bbb N$ and $\frac d2$ of these have $u<v$ (well, $\frac{d-1}2$ for square $a$). Each such factorisation gives rise to a solution $a=x^2-y^2$ with $x=\frac{u+v}2$, $y=\frac{v-u}2$ (and vice versa: $a=x^2-y^2$ implies $a=uv$ with $u=x-y$ and $v=x+y$). So your question really is: Among the numbers $1, 11, 111, \ldots$, which is the first with six or more divisors? As $111=3\cdot 37$, $1111=11\cdot 101$, $11111=41\cdot 271$ and $111111=3\cdot 7\cdot 11\cdot 13\cdot 37$ we confirm that $111111$ is the first such number and in fact has $16$ such solutions: \begin{align}111111&=55556^2 - 55555^2\\ &=18520^2 - 18517^2\\ &=7940^2 - 7933^2\\ &=5056^2 - 5045^2\\ &=4280^2 - 4267^2\\ &=2656^2 - 2635^2\\ &=1700^2 - 1667^2\\ &=1520^2 - 1483^2\\ &=1444^2 - 1405^2\\ &=760^2 - 683^2\\ &=656^2 - 565^2\\ &=556^2 - 445^2\\ &=460^2 - 317^2\\ &=356^2 - 125^2\\ &=344^2 - 85^2\\ &=340^2 - 67^2 \end{align}

• How did you find all of the ways to write 111111?? Dec 27, 2015 at 22:46
• ^As his solution explains, if you write $111111 = uv$ for some positive integers $u > v$, then $x = \tfrac{u+v}{2}$ and $y = \tfrac{u-v}{2}$ will be a solution to $x^2-y^2 = 111111$. Once he has the prime factorization $111111 = 3 \cdot 7 \cdot 11 \cdot 13 \cdot 37$, it is easy to list out all the pairs of factors $(u,v)$ and plug them into the formula. Dec 27, 2015 at 22:51
• And the next time we hit a prime is with nineteen 1s (that is $\frac{10^{19}-1}{9}$), so it has only the trivial representation $1111111111111111111 = 555555555555555556^2 - 555555555555555555^2$. Dec 28, 2015 at 12:06
• is $d=3$ in the second case? Dec 17, 2020 at 17:16

All numbers up to $11111$ have at most $2$ prime factors, and hence these numbers cannot be expressed as difference of squares is 3 different ways.

This follows from $a^2 - b^2 = (a+b)(a-b)$ and with at most 2 prime factors and of course $1$ and itself, there are only $2$ ways to write $a+b$, $a-b$.

$11$ is prime, $111 = 37 \times 3$, $1111 = 11 \times 101$ and $11111 = 41 \times 271$.

In fact, $111111 = 3 \times 7 \times 11 \times 13 \times 37$, so it can be expressed as difference of squares in many ways. (You can work out that there are 16, or use a known formula).

Some more explanation (Answering comments)

Take $111111 = 3 \times 37037 = a^2 - b^2$, then $a+b = 37037$, $a-b = 3$, we get $a = 18520$, $b = 18517$. We can continue this exercise for all the factorizations of this number and as stated above, there are $16$ such ways, so prime factorization does matter.

• This does not answer my question, as I asked whether it can be done in three different ways. Dec 27, 2015 at 22:25
• Why does the number of prime factors matter? (I didn't downvote you, but here's an upvote!) Dec 27, 2015 at 22:35
• that is exactly what I was saying to you Dec 27, 2015 at 22:36

Note that, if we take $(s_n)=(1, 11, 111, 1111, \cdots),$ then easily we can see that $$s_n=\dfrac{10^n-1}{9}$$ and this lead us to find the number of solution for the Diophantine equation $\dfrac{10^n-1}{9}=x^2-y^2.$ Since $9=3^2$ this reduced to $$10^n=u^2-v^2+1$$ where both $u$ and $v$ are multiples of $\color{Green}{3}.$

In general, for any $n\in\Bbb{N},$ $10^n-1$ has two factors $p, q$ such that $p\gt q\ge 1$
satisfying $$10^n-1=u^2-v^2=(u-v)(u+v)=pq.$$ Therefore we can take $$u=\dfrac{p+q}{2} ,\,\,\,\text{and}\,\,\,\,\ v=\dfrac{p-q}{2}.$$ Now,

For $n=1$: $$9=3^2 \,\,\,\,\,\text{and}\,\,\,\,\, (p, q)\in\{(9,1),(3,3)\}.$$ For $n=2$: $$99=3^2\times 11 \,\,\,\,\,\text{and}\,\,\,\,\, (p, q)\in\{(99,1),(33,3),(11,9)\}.$$ For $n=3$: $$999=3^3\times 37 \,\,\,\,\,\text{and}\,\,\,\,\, (p, q)\in\{(999,1),(333,3),(111,9),(37,27)\}.$$
For $n=4$: $$9999=3^2\times 11\times 101 \,\,\,\,\,\text{and}\,\,\,\,\, (p, q)\in\{(9999,1),(3333,3),(1111,9),(909,11),(303,33),(101,99)\}.$$
And so on. Finally choose $p, q$ which are multiples of $3.$ Number of such pairs will solve your problem.

If you only want to check for $1, 11, 111, 1111, 11111$. Just try to solve the following diophantine equation: $x^2-y^2 = a$ where "$a$" is one of de $1, 11...$ therefore the diference of squares is $(x-y)(x+y)$ then factorize a and the following is just permuting the factos of $A.$

For $a=1$ is obvios. $1=1\cdot 1$, hence $(x-y)=1$ and $(x+y)=1$, so $x=1$ and $y=0$ is the unique solution.

For $x=11=11\cdot 1$ and $x+y \geq x-y$ then $(x+y)=11$ and $(x-y)=1$ .Hence only one solution.

For $a=111=37\cdot 3\cdot 1$ these are the possibilities $(x+y)=37$ and $(x-y)=3$; $(x+y)=111$ and $(x-y)=1$. Solve this.

For $a=1111$ the same $1111=101 \cdot 11 \cdot 1$

For $a=11111=271 \cdot 41 \cdot 1$

Sorry that I don't know how to write it corretcly

• Can you elaborate on how this helps to answer my question? I'm unsure of how writing the factors of the numbers helps. Dec 27, 2015 at 22:30
• If I undestand correctly the question, you are asking if 1, 11, 111, 1111, 11111 can be written in different ways as diference of squares. Then I proposed you to solve a diophantine equation. And the way to solve it is to factor the difference x^2-y^2=(x+y)(x-y) this must be equal to one of the numbers and by factorizing the numbers you can do x+y= a factor and (x-y)= the number divided by the factor Dec 27, 2015 at 22:33
• Dec 28, 2015 at 9:36