# Find all odd solutions for $n$ for which $3n^2+8$ is equal to a number in base $10$ which is formed by only one digit(e.g.-$222,8888888,4,99$ etc.)

Find all odd solutions for $n$ for which $3n^2+8$ is equal to a number in base $10$ which is formed by only one digit(e.g.-$222,8888888,4,99$ etc.)

My approach:-

Let $3n^2+8=...mmmmmm...$($k$ digits)
Applying 'Sum of GP',
$$\frac{m(10^k-1)}{9}=3n^2+8$$ $$m×10^k=27n^2+72+m$$

Now, if $n$ is odd, $27n^2+72$ can have $5,7,9$ as last digits. Now I can look into what can be the last digits of $m$ and analyse further, but only with the help of somebody.

• Hint: $n^2$ ends only in $0,1,4,5,6,9$. – DynamoBlaze Jun 25 '18 at 8:26
• @MalayTheDynamo Not only, but also $1,5,9$ as $n$ is odd – ami_ba Jun 25 '18 at 8:28
• @MalayTheDynamo I used this fact to cal calculate the last digits of $27n^2+72$. – ami_ba Jun 25 '18 at 8:30
• Then $m=5,7,9$. Substitute and try to solve. – DynamoBlaze Jun 25 '18 at 8:34
• @MalayTheDynamo: Wrong, $m$ can be only 1, 3 or 5. And it cannot be 3 if you analyze the starting expression. So $m$ is either 1 or 5. – Oldboy Jun 25 '18 at 8:38

Let $k$, $m$ and $n$ be positive integers with $m$ less than $10$ and $n$ odd, such that $$3n^2+8=m\frac{10^k-1}{9}.$$ The above can be rewritten as $$27n^2+72+m=10^km.$$ A routine check shows that only solution with $k\leq2$ is $(k,m,n)=(2,1,1)$, so suppose $k>2$. Then $10^k\equiv0\pmod{8}$ and $n^2\equiv1\pmod{8}$ because $n$ is odd, so reducing the above mod $8$ shows that $m\equiv5\pmod{8}$, and hence $m=5$. This leaves us with $k$ and $n$ such that $$27n^2+77=5\cdot10^k.$$ Reducing mod $7$ shows that $6n^2\equiv5\cdot3^k\pmod{7}$, from which it follows that $k$ is even, say $k=2\ell$, because $3$, $5$ and $6$ are not squares mod $7$. Then in $\Bbb{Z}[\alpha]:=\Bbb{Z}[X]/(X^2-15)$ we have $$(9n-10^\ell\alpha)(9n+10^\ell\alpha)=3\cdot(27n^2-5\cdot10^k)=-3\cdot77.$$ Unfortunately $\Bbb{Z}[\alpha]$ is not a unique factorization domain, but of course it is a Dedekind domain, where the ideals $(3)$, $(7)$ and $(11)$ factor into prime ideals as follows: $$(3)=(3,\alpha)^2\qquad (7)=(7,1+\alpha)(7,1-\alpha)\qquad (11)=(2+\alpha)(2-\alpha).$$ This yields the identity of ideals $$(9n-10^\ell\alpha)(9n+10^\ell\alpha) =(3,\alpha)^2(7,1+\alpha)(7,1-\alpha)(2+\alpha)(2-\alpha).$$ As the two factors on the left hand side are conjugate, each must contain precisely one prime factor of $(3)$, $(7)$ and $(11)$. So the ideals $(9n\pm10^\ell\alpha)$ are one of the two conjugate pairs of ideals \begin{eqnarray*} (3,\alpha)(7,1\pm\alpha)(2\pm\alpha)&=&(3\mp4\alpha),\\ (3,\alpha)(7,1\pm\alpha)(2\mp\alpha)&=&(27\mp8\alpha). \end{eqnarray*} This means that there is a unit $u\in\Bbb{Z}[\alpha]^{\times}$ such that either $$9n+10^\ell\alpha=u\cdot(3\pm4\alpha) \qquad\text{ or }\qquad 9n+10^\ell\alpha=u\cdot(27\pm8\alpha).$$ Knowing Dirichlets unit theorem it is not hard to check that $\Bbb{Z}[\alpha]^{\times}=\langle-1,4+\alpha\rangle$. So first suppose that for some $b\in\Bbb{Z}$ we have $$9n+10^\ell\alpha=\pm(4+\alpha)^b(27\pm8\alpha)\label{1}\tag{1}.$$ Identifying $\alpha$ with $\sqrt{15}$ we see that $$9n+10^{\ell}\sqrt{15}>0\qquad\text{ and }\qquad 27-8\sqrt{15}<0,$$ so the two $\pm$-signs in (\ref{1}) take the same value. Reducing equation (\ref{1}) mod $3$, i.e. evaluating in $\Bbb{F}_3[\varepsilon]$ with $\varepsilon^2\equiv15\equiv0$, we find that $$\pm(4+\varepsilon)^b(27\pm8\varepsilon) \equiv\pm(1+\varepsilon)^b(0\pm2\varepsilon) \equiv2\varepsilon, \qquad\text{ and }\qquad 9n+10^\ell\varepsilon\equiv\varepsilon$$ a contradiction. Then there must be some $b\in\Bbb{Z}$ such that $$9n+10^\ell\alpha=\pm(4+\alpha)^b(3\pm4\alpha).$$ Now reducing mod $8$, i.e. evaluating in the ring $(\Bbb{Z}/8\Bbb{Z})[i]$ with $i^2\equiv15\equiv-1$, we find that $$\pm(4+i)^b(3\pm4i) \equiv\pm(i^b+4bi^{b-1})(3\pm4i) \equiv\pm(3i^b+4bi^{b-1}\pm4i^{b+1}),$$ and $9n+10^{\ell}i\equiv n+2^{\ell}i$. If $b$ is odd then $i^{b+1}\equiv-i^{b-1}\equiv\pm1$ and we find that $$n\equiv\pm(4bi^{b-1}\pm4i^{b+1})\equiv\pm4(4b\pm1) \qquad\text{ and }\qquad 2^a\equiv\pm3i^{b-1}\equiv\pm3.$$ Both are impossible as $n$ is odd and $2^a\equiv0,1,2,4$. So $b$ is even and hence $$n\equiv\pm3i^b\equiv\pm3 \qquad\text{ and }\qquad 2^a\equiv4i^b\pm4bi^{b-2}\equiv4i^b\equiv4.$$ This shows that $a=2$, and so $k=4$. Hence the only solution with $k>2$ is $(k,m,n)=(4,5,43)$.

This is only a partial answer. User quasi has posted a similar partial answer with a nice improvement.

Let's start from the OP's equation $m\times10^k=27n^2+72+m$, where $1\le m\le9$ is the repeated digit and $k$ is the number of repeats of the digit $m$. Note that $n\not=0$ implies $3n^2+8\ge11$, which implies $k\ge2$.

Since the problem only asks for odd values of $n$ that satisfy the equation, let's start by looking mod $8$:

$$27n^2+72+m\equiv3+m\equiv \begin{cases} 4m&\text{if }k=2\\ 0&\text{if }k\ge3\\ \end{cases}$$

Thus for $k=2$ we can only have $m=1$ or $9$, while for $k\ge3$ we can only have $m=5$.

Now $m=1$ and $k=2$ leads to $11=3\cdot1^2+8$, while $m=9$ can be dismissed, since $3n^2+8$ is not divisible by $3$, much less $9$.

We're left with the case $m=5$ with $k\ge3$, at which point it's convenient to return to the original equation, written as

$$n^2={555\ldots547\over3}$$

It's easy to see that we need $k\in\{4,7,10,\ldots\}$. (Note: User quasi eliminates the odd possibilities with a nice mod $11$ argument.) Letting $k=3h+4$, we can rewrite things as

$$n^2=185185\ldots1850000+1849=1850000\times{1000^h-1\over1000-1}+43^2$$

or

$$37\times2^4\times5^5\times{1000^h-1\over999}=(n+43)(n-43)$$

It's clear that $n=43$ is a solution with $h=0$, i.e., $5555=3\cdot43^2+8$ joins $11=3\cdot1^2+8$ as a solution. But it's less clear if there are solutions with $h\gt0$.

The best I can say is that, since $5$ cannot divide both $n+43$ and $n=43$, we must have $5^5=3125$ divide one of them. Allowing $n$ to be either positive or negative, we may, without loss of generality, assume it's $n-43$. Thus, since $n$ is required to be odd, we can write $n=6250N+43$ with $N\in\mathbb{Z}$. This reduces things to

$$37\times8\times{1000^h-1\over999}=N(3125N+43)$$

Now $N$ and $3125N+43$ cannot both be even, so one of them must be divisible by $8$. When the modular dust settles we have $N\in\{0,7\}$ mod $8$ and $N\in\{0,4\}$ mod $37$. The Chinese remainder theorem tells us $N\in\{0,111,152,263\}$ mod $296$, that is, $n$ is of the form

$$n=(43+6250r)+1850000M$$

with $r\in\{0,111,152,263\}$ and $M\in\mathbb{Z}$. But at this point I'm stuck. Maybe someone else can see how to proceed from here, or find some other, better, approach.

• Nice argument (+1), even if it's only a partial solution. In my attempt, assuming $k > 2$, I found the necessary conditions $m=5$, and $k\equiv 4\;(\text{mod}\;6)$, but was unable to fully resolve that case, so it looks like we reached essentially the same place before reaching an apparent dead end. Does DanielV's argument really work to finish the problem? – quasi Jun 26 '18 at 0:08
• @quasi, I like your mod $11$ argument improving my $k\equiv4$ mod $3$ to $k\equiv4$ mod $6$. DanielV's answer has been deleted for repair, so I've dropped the references to it. – Barry Cipra Jun 26 '18 at 12:53
• You can a also use $\bmod 7$. If you try $k\ equiv 1 \bmod 6$ your intended square has residue $-1 \bmod 7$. – Oscar Lanzi Jun 26 '18 at 15:40
• @OscarLanzi, nice observation! – Barry Cipra Jun 26 '18 at 15:54
• Since $n^2$ has an even number of $185$ blocks followed by $1849$, the alternating 3-digist sum test for divisibility by $7, 11, 13$ implies $n^2\equiv 1849$ in each of these modulo. This forces $n \equiv \pm 43 \bmod 1001$. – Oscar Lanzi Jun 26 '18 at 17:38

Here's my derivation of the following partial results . . .

Consider the equation $$3n^2+8=m\left(\frac{10^{\,k}-1}{9}\right)$$ or equivalently, $$27n^2+72+m=m(10^{\,k})$$ to be solved for positive integers $m,k,n$ subject to the restrictions

• $n$ is odd.$\\[4pt]$
• $m\le 9$.

An immediate solution, which we'll call the trivial solution, is the triple $(m,k,n)=(1,2,1)$.

It's easily verified that the triple $(m,k,n)=(5,4,43)$ is also a solution, which shows that there is at least one nontrivial solution.

Claims:

• If $(m,k,n)$ is a nontrivial solution, then $m=5$, and $k\equiv 4\;(\text{mod}\;6)$.$\\[4pt]$
• The number of solution triples $(m,k,n)$ is finite.

Proof:

Suppose the triple $(m,k,n)$ is a nontrivial solution.

Then $n \ge 3$, hence $k > 2$.

First, we show $m=5$ . . .

Since $k > 2$, we have $10^k\equiv 0\;(\text{mod}\;8)$, and since $n$ is odd, we have $n^2\equiv 1\;(\text{mod}\;8)$, hence \begin{align*} &27n^2+72+m=m(10^{\,k})\\[4pt] \implies\;&27n^2+72+m\equiv m(10^{\,k})\;(\text{mod}\;8)\\[4pt] \implies\;&3+m\equiv 0\;(\text{mod}\;8)\\[4pt] \implies\;&m\equiv 5\;(\text{mod}\;8)\\[4pt] \implies\;&m=5\\[4pt] \end{align*} so our new equation is $$27n^2+77=5(10^{\,k})$$ or equivalently $$54n^2+154=10^{\,k+1}$$ Next, we show that $k$ is even . . .

Suppose instead that $k$ is odd. \begin{align*} \text{Then}\;\;&54n^2+154=10^{\,k+1}\\[4pt] \implies\;&54n^2+154\equiv 10^{\,k+1}\;(\text{mod}\;11)\\[4pt] \implies\;&-n^2\equiv (-1)^{k+1}\;(\text{mod}\;11)\\[4pt] \implies\;&-n^2\equiv 1\;(\text{mod}\;11)\\[4pt] \implies\;&n^2\equiv -1\;(\text{mod}\;11)\\[4pt] \end{align*} contradiction, since $-1$ is not a square, mod $11$.

Hence, $k$ is even, as claimed.

Next, we show that $k \equiv 4\;(\text{mod}\;6)$ . . .

Note that the multiplicative order of $10$, mod $27$, is $3$, hence \begin{align*} &10^{\,k+1}=54n^2+154\\[4pt] \implies\;&10^{\,k+1}=-8\;(\text{mod}\;27)\\[4pt] \implies\;&10^{\,k+1}\equiv -8+108\;(\text{mod}\;27)\\[4pt] \implies\;&10^{\,k+1}\equiv 10^{\,2}\;(\text{mod}\;27)\\[4pt] \implies\;&10^{\,k-1}\equiv 1\;(\text{mod}\;27)\\[4pt] \implies\;&3{\,\mid\,}(k-1)\\[4pt] \implies\;&k \equiv 1\;(\text{mod}\;3)\\[4pt] \implies\;&k \equiv 4\;(\text{mod}\;6)\qquad\text{[since $k$ is even]}\\[4pt] \end{align*}

Thus, we've proved that for any nontrivial solution triple $(m,k,n)$, we must have $m=5$, and $k \equiv 4\;(\text{mod}\;6)$.

Next, we show that the number of solution triples $(m,k,n)$ is finite.

Since there is only one trivial solution, we need only consider nontrivial solutions.

Thus, suppose the triple $(m,k,n)=(5,k,n)$ is a nontrivial solution.

Since $k \equiv 4\;(\text{mod}\;6)$, $k-1$ is a multiple of $3$.

Let $w={\displaystyle{10^{\frac{k-1}{3}}}}$, let $x=150w$, and let $y=1350n$. \begin{align*} \text{Then}\;\;&10^{\,k+1}=54n^2+154\\[4pt] \implies\;&100(10^{\,k-1})=54n^2+154\\[4pt] \implies\;&100w^3=54n^2+154\\[4pt] \implies\;&27n^2=50w^3-77\\[4pt] \implies\;&27n^2=50w^3-77\\[4pt] \implies\;&(9n)^2=150w^3-231\\[4pt] \implies\;&150^{\,2}(9n)^2=150^{\,3}w^3-150^{\,2}(231)\\[4pt] \implies\;&(1350n)^2=(150w)^3-5197500\\[4pt] \implies\;&y^2=x^3-5197500\\[4pt] \end{align*} which has only finitely many integer solutions, since it's known that for any fixed nonzero integer $c$, the equation $y^2=x^3+c$ has only finitely many integer solutions.

It follows that for our equation, the number of solution triples $(m,k,n)$ is finite.

This completes the proof of the claimed results.

Update:

With help from Yong Hao Ng, we can now obtain a complete solution . . .

Using Sage commands for finding integer points on elliptic curves, Yong Hao Ng confirms that the only pair $(x,y)$ of positive integers which satisfy the equation $y^2=x^3-5197500$ is the pair $(x,y)=(1500,58050)$, which corresponds to the solution triple $(m,k,n)=(5,4,43)$.

Therefore the only solutions are $(m,k,n)=(1,2,1)$ and $(m,k,n)=(5,4,43)$.

• +1 Nice progress. Note that since $k\equiv4\pmod6$ we have $10^k\equiv3\pmod{13}$. This in turn implies $n\equiv5,8\pmod{13}$... – Servaes Jun 26 '18 at 13:41
• @Servaes: Yes, except it should be "This in turn implies $n\equiv 4,9\;(\text{mod}\;13)$". – quasi Jun 26 '18 at 23:52
• Nicely done. I noticed that sagemath says that the only integral points are $(x,y) = (1500 , \pm 58050)$, which would give $n = 387$. We can then check that $3n^2+8 = 449315$ does not give a desired solution, so $n\in \{1,43\}$ is the complete list. – Yong Hao Ng Jun 27 '18 at 2:40
• @Yong Hao Ng: Cool! But note that $y=58050$ gives $n=43$, not $387$. In any case, with your help, the problem is now fully solved! – quasi Jun 27 '18 at 2:49
• Oops, I divided by $150$ instead of $1350$, so sorry about that. – Yong Hao Ng Jun 27 '18 at 2:54