# Elementary number theory problem about finding a square number with digits with certain properties

Here's the problem I am working on:-

Find,showing your method, a six-digit integer n with the following properties:

$$(1)$$ $$n$$ is a perfect square

$$(2)$$ the number formed by the last three digits of $$n$$ is exactly one greater than the number formed by the ﬁrst three digits of $$n$$. (Thus $$n$$ might look like $$123124$$; although, this is not a square.)"

Here's my approach:

Consider the first $$3$$ digits of $$n$$ as $$x$$

Now, $$n=1000x+(x+1)$$

Because $$n$$ is a perfect square,

$$m^2=1001x+1$$

Using the difference of two squares identity:

$$(m+1)(m-1)=1001x$$

Now $$1001=m+1$$ as if $$1001$$ is $$m-1$$, then $$1003=m+1=x$$, and this is not possible since $$x$$ is a $$3$$-digit number.

Hence, $$x=999$$

Now, here the problem arises.

If $$x=999$$, then the last $$3$$ digits should be $$999+1=1000$$ making the number:

$$9991000$$

However, this is a $$7$$ digit number, making the initial condition false.

Where did I go wrong?

• $1001$ is not prime. – Jaap Scherphuis Aug 21 '18 at 14:22
• just for your information: Answer 1: $n = 184$, $m = 183$, $i = 428$, $q = 183184$ Answer 2: $n = 329$, $m = 328$, $i = 573$, $q = 328329$ Answer 3: $n = 529$, $m = 528$, $i = 727$, $q = 528529$ Answer 4: $n = 716$, $m = 715$, $i = 846$, $q = 715716$ is what I've found with a tiny python script. Because I don't provide a mathematical answer, it's just a comment ($q = i^2$, $i$ runs from 300 to 999). – Ronald Aug 21 '18 at 14:28

Everything is fine upto

(m+1)(m-1)=1001x


After that, you asume that it implies $$(m+1=1001 \land m-1 = x) \lor (m+1=x \land m-1=1001)$$

This is not true, for instance:

11*9=99=33*3, yet, we don't have 33=11 nor 9=3

Try looking at it this way

$m^2-1 = 1001x$ if and only if $m \equiv \pm 1 \pmod{7}$ , $m \equiv \pm 1 \pmod{11}$, and $m \equiv \pm 1 \pmod{13}$

\begin{array}{r|rrr} n & \mod 7 & \mod{11} & \mod{13} \\ \hline 11\cdot 13 = 143 & 3 & 0 & 0 \\ 7 \cdot 13 =91 & 0 & 3 & 0 \\ 7 \cdot 11=77 & 0 & 0 & 12 \\ \hline -2 \cdot 143 = -286 & 1 & 0 & 0 \\ 4 \cdot 91 = 364 & 0 & 1 & 0 \\ -1 \cdot 77 = -77 & 0 & 0 & 1 \\ \hline \end{array}

So $m \equiv \pm 286 \pm 364 \pm 77 \pmod{1001}$

\begin{array}{r|r|} m & m \pmod{1001} & m^2 \\ \hline 286 + 364 + 77 & 727 & 528529 \\ 286 + 364 - 77 & 573 & 328329 \\ 286 - 364 + 77 & 0 & 0 \\ 286 - 364 - 77 & 846 & 715716 \\ -286 + 364 + 77 & 155 & 24025 \\ -286 + 364 - 77 & 1 & 1 \\ -286 - 364 + 77 & 428 & 183184 \\ -286 - 364 - 77 & 274 & 75076 \\ \hline \end{array}

Solve using Chinese remainder theorem

as $1001=13\cdot7\cdot11,$

$$m\equiv\pm1\pmod{13}$$

$m\equiv\pm1\pmod7$

$m\equiv\pm1\pmod{11}$

But $m\not\equiv\pm1\pmod{1001}$

• @Fabio, Thanks for the observation – lab bhattacharjee Aug 21 '18 at 15:23