# The natural numbers $a, b, c$, formed by the same $n$ digits $x$, $n$ digits $y$, and $2n$ digits $z$ satisfy $a^2 + b = c$

Given that the natural numbers $$a, b, c$$ are formed by the same $$n$$ digits $$x$$, $$n$$ digits $$y$$, and $$2n$$ digits $$z$$ respectively. For any $$n \geq 2$$, find the digits $$x, y, z$$ such that $$a^2 + b = c$$

Greetings, I was doing this question above and I couldn't figure out how to do.

Here's my progress so far:

The relation $$a^2 + b = c$$ means $$(xxx...x)^2 + (yy..yy) = (zzz...zz)$$ where the $$x\text{ and }y$$ are $$n$$ in number and the $$z$$ is in $$2n$$ in number. This simplifies to $$x^2(11···1)^2 +y(11···1) = z(11···1)$$ and I couldn't figure out further. :(

By some trial and error, I found $$(333)^2 + 222 = 111,111$$.

Any help would be appreciated. I tried but couldn't find out even a similar question somewhere else. Please inform if this question has been asked before.

Thank You

Let

$$f(n) = \sum_{i=0}^{n-1} 10^i \tag{1}\label{eq1}$$

Thus, as you've shown,

$$x^2 f^2(n) + yf(n) = zf(2n) \implies f(n)\left(x^2 f(n) + y\right) = zf(2n) \tag{2}\label{eq2}$$

Also, note that

$$f(2n) = 10^n f(n) + f(n) = f(n)\left(10^n + 1\right) \tag{3}\label{eq3}$$

Thus, substituting that into \eqref{eq2} and dividing by the common factor of $$f(n)$$ gives

$$x^2f(n) + y = z(10^n + 1) \tag{4}\label{eq4}$$

First, there's the trivial case of $$x = y = z = 0$$. The rest of this solution will assume that $$z \gt 0$$. Next, note that

$$f(n) = \frac{10^n - 1}{9} \tag{5}\label{eq5}$$

Thus, substituting \eqref{eq5} into \eqref{eq4} gives

\begin{equation}\begin{aligned} x^2\left(\frac{10^n - 1}{9}\right) + y & = z(10^n + 1) \\ x^2(10^n - 1) + 9y & = 9z(10^n + 1) \\ x^2(10^n) - x^2 + 9y & = 9z(10^n) + 9z \\ (x^2 - 9z)(10^n) & = x^2 - 9y + 9z \end{aligned}\end{equation}\tag{6}\label{eq6}

The RHS is less than $$100$$ (update: actually, it's less than $$1000$$, but it can be $$100$$; see the end for more details) and greater than $$-10$$, so for $$n \ge 2$$, this means that $$x^2 - 9z = x^2 - 9y + 9z = 0$$. Note $$x^2 - 9z = 0$$ occurs only for $$x = 3, z = 1$$ and $$x = 6, z = 4$$. This gives, from $$x^2 - 9y + 9z = 0$$, that $$y = 2$$ for the first part and $$y = 8$$ for the second part.

Another way to see this is that the RHS of \eqref{eq4}, as $$z$$ is a digit, in base $$10$$, would be $$z$$, followed by $$n - 1$$ zeros, and then $$z$$ again. On the LHS, $$y$$ is just a single digit. This means for $$n \ge 2$$, the digits in $$x^2f(n)$$ must basically all "disappear" when $$y$$ is added, i.e., $$x^2f(n)$$ must be just slightly less (i.e., $$\lt 9$$) than a power of $$10$$. Checking the squares of $$x$$ multiplied by $$11$$, you can see this only occurs if $$x = 3$$, so $$x^2 = 9$$ (with it being $$1$$ less than a power of $$10$$), or $$x = 6$$ so $$x^2 = 36$$ (with it being $$4$$ less than a power of $$10$$). For $$x = 3$$, this means $$z = 1$$, which requires that $$y = 2$$, while for $$x = 6$$, this means $$z = 4$$ and $$y = 8$$.

Note the second solution comes from the first one by multiplying by $$4$$ in \eqref{eq4}. You can see this changes $$x = 3$$ to $$x = 6$$, $$y = 2$$ to $$y = 8$$ and $$z = 1$$ to $$z = 4$$.

In conclusion, there are $$3$$ solutions, with the sets of digits $$(x,y,z)$$ being $$(0,0,0)$$, $$(3,2,1)$$ and $$(6,8,4)$$.

Update: As I saw from the answer by fleablood, I made a mistake in my handling of \eqref{eq6}. The RHS of it is definitely less than $$1000$$, so what I wrote above is true for $$n \ge 3$$. However, the RHS can be equal to $$100$$, which means that for $$n = 2$$, there's also the solution $$(8,3,7)$$.

• Great Answer! +1. However, there is one more solution I found that didn't make it in the question. It is $666^2 + 888 = 444,444$ – Vasu090 Aug 4 '19 at 5:26
• @Vasu090 Thanks. However, as you pointed out & I realized later, my solution is the only one for larger values of $n$. I'm working on determining & proving it for all the various cases. Please be a bit patient with me while I work on solving this fully. Thanks. – John Omielan Aug 4 '19 at 5:31
• OK. No problem John. Thank you for taking the time to answer my question. Really appreciate it. :) – Vasu090 Aug 4 '19 at 5:33
• @Vasu090 I realized my mistake and have corrected it. Sorry for not seeing it sooner. As you can see, there's actually $2$ sets of digits $x,y,z$ which work. The second solution includes $66^2 + 88 = 4444$, your value for $n = 3$, $6666^2 + 8888 = 4444 4444$, etc. – John Omielan Aug 4 '19 at 5:50
• @Vasu090 I determined there's a simpler, more direct way to determine the solutions. I've added this to my answer, but also left the original arguments as well. – John Omielan Aug 4 '19 at 6:15

If we let $$1_n= \underbrace{1111....1}_{n}$$

$$a^2 + b = c$$

$$\frac {a^2}{1_n} + \frac {b}{1_n} = \frac {c}{1_n}$$

$$x^2*1_n + y = z*(10^n + 1)$$

Let's think about what that means:

If $$x^2 = 10j + k$$ we have

$$10j + k + y \equiv z$$. And we carry $$j$$ or $$j+1$$

Then we have $$j +k (+1)\equiv 0$$. Which means $$j+k(+1) = 10$$.

This can occur if:

$$x=1$$ so $$k=1$$ and $$j=0$$, $$j+k(+1) \equiv 1,2 \not \equiv 0$$.

$$x = 2$$ so $$k=4$$ and $$j=0$$, $$j+k(+1) \equiv 4,5\not equiv 0$$.

$$x=3$$ so $$k=9$$ and $$j=0$$ and $$j+k(+1)\equiv 0$$ if we carry.

$$x=4$$ so $$k=6$$ and $$j=1$$ and $$j+k(+1)\not \equiv 0$$.

$$x=5$$ so $$k=5$$ and $$j=2$$ and $$j+k(+1)\not \equiv 0$$.

$$x=6$$ so $$k=6$$ and $$j=3$$ and $$j+k+1\equiv 0$$.

$$x=7$$ so $$k=9$$ and $$j=4$$ and $$j+k(+1) \not \equiv 0$$.

$$x=8$$ so $$k =4$$ and $$j=6$$ and $$j+k\equiv 0$$.

$$x=9$$ so $$k =1$$ and $$j = 8$$ and $$j+k(+1)\equiv 0$$.

Now we repeat this and carry again to get the third digit. Assume $$n > 2$$ As $$j+k(+1) = 10$$ we must carry $$1$$ and get $$j+k+1$$ so this can only happen if $$j+k+1 = 10$$; not $$j+k=10$$.

So this can occur if:

$$x=3; k=9;j=0$$ and $$z= j+1=1$$ and $$9+y \equiv 1$$ so $$y = 2$$.

$$x=6; k=9;j=3$$ and $$z = j+1 = 4$$ and $$36+y\equiv 4$$ so $$y=8$$.

$$x=9; k=1; j=8$$ and $$z = j+1=9$$ and $$81+y\equiv 9$$ so $$y=8$$ but.. then we don't carry the $$1$$. we must have $$y=18$$ but that's not a single digit.

But if $$n = 2$$ we can have:

$$x^2 = 10j + k$$ and $$x^2*11 = 100j + 10(k+j) + k$$ and $$x^2*11 + y= 100j + 10(k+j) + k+y$$ where $$k+y = z$$ and $$k+j = 10$$ and $$j+1 = z$$

Then we can have $$x=8;k=4;j=6;z=7$$ and $$y = 3$$. (i.e $$8^2*11 + 3= 707$$ or $$(88)^2 + 33 = 7777$$

$$\underbrace{1\ldots 1}_{2n}= \underbrace{1\ldots 1}_{n}\underbrace{1\ldots 1}_{n}= \underbrace{1\ldots 1}_{n}\underbrace{0\ldots 0}_{n}+\underbrace{1\ldots 1}_{n}= \underbrace{1\ldots 1}_{n}\cdot1\underbrace{0\ldots 0}_{n}+\underbrace{1\ldots 1}_{n}= \underbrace{1\ldots 1}_{n}\cdot(9\cdot \underbrace{1\ldots 1}_{n}+1)+\underbrace{1\ldots 1}_{n}$$

So if we set $$t=\underbrace{1\ldots1}_n$$ we can rewrite the equation

$$x^2\cdot \underbrace{1\ldots 1}_{n}^2+y\cdot \underbrace{1\ldots 1}_{n}=z\cdot \underbrace{1\ldots 1}_{2n}$$ as $$xt^2+yt=z(t(9t+1)+t)$$

This simplifies to $$t(9z-x^2)+(2z-y)=0 \tag{1}$$

Now we have two cases:

Case 1: $$9z-x^2\ne0$$:

Then we have

$$t=\frac{2z-y}{9z-x^2}$$

Because of $$x,y,z \in \{0,\ldots,9\}$$ and $$9z-x^2\ne0$$ we have $$|2z-y|\le18$$ and $$|9z-x^2|\ge1.$$ So $$|t|\le18$$, and therefore $$t=11$$.

If we substitute this in $$(1)$$ we get

$$11x^2+2y=101z$$

Taking this equation $$\pmod {11}$$ we get

$$y\equiv 2z \pmod{11}$$

and we can calulate $$y$$ for every digit $$z$$. For $$z=5$$ there is no valid $$y$$, because $$y=10$$ is not a digit. From $$z$$ and $$y$$ we can calculate $$x$$. For $$z=2$$ and $$y=4$$ there is no valid $$x$$ because the calculated value is a non integer square root.

z y x
0 0 0
1 2 3
2 4 *
3 6 *
4 8 6
5 * *
6 1 *
7 3 8
8 5 *
9 7 *


Case 2: $$9z-x^2=0$$

Then we also have

$$2z-y=0$$

The number $$9z$$ must be a perfect square and therefore $$z$$ must be a perfect square. So we can calculate

z x y
0 0 0
1 3 2
4 6 8
9 9 *


Because $$9z-x^2=2z-y=0$$ the equation holds for arbitrary $$t.$$

So we can conclude that

$$88^2+33=7777$$

and for every $$n\ge2$$

$${\underbrace{3\ldots3}_{n}}^2+\underbrace{2\ldots 2}_{n}=\underbrace{1\ldots1}_{2n}$$ $${\underbrace{6\ldots6}_{n}}^2+\underbrace{8\ldots 8}_{n}=\underbrace{4\ldots4}_{2n}$$

These are the only solutions.