Given any finite string of number, is it true there exists a perfect square whose leading numbers are the string

714 Views Asked by At

Given any finite string of number, is it true there exists a perfect square whose leading numbers are the string? For example, given the string 123456, can I find a perfect square with leading digits 123456?

I think the answer is a positive one because number of integers with the string are infinite so one can keep increasing the number to obtain a perfect square? Appreciate all advice, thank you

2

There are 2 best solutions below

0
On

The answer is yes. In fact, we can find infinitely many such perfect squares. In your particular case, $$111,111^2=12,345,654,321$$ and $$341,364^2=123,456,660,496$$


Here is the proof. Let the natural number coming from the string be $a$. We want to find natural numbers $n$, $b$, and $c$ such that $$b^2=a\cdot 10^n+c \quad\text{where}\quad 0\le c<10^n$$

This makes $b^2$ a perfect square with the leading digits of $a$.

For all $n$ let $d_n=\lfloor \sqrt{a\cdot 10^n} \rfloor$, where the symbol is the greatest integer function. Then clearly $$d_n+1=\sqrt{a\cdot 10^n}+r \quad\text{for some real $0<r\le 1$},$$ $$(d_n)^2\le a\cdot 10^n,\quad\text{and}$$ $$(d_n+1)^2> a\cdot 10^n$$

We get

$$\begin{align} (d_n+1)^2 &= (\sqrt{a\cdot 10^n} +r)^2 \\ &=a\cdot 10^n+ 2r\sqrt{a\cdot 10^n}+r^2 \end{align}$$

We can find some $n$ such that $2r\sqrt{a\cdot 10^n}+r^2<10^n$ since the right hand side of that inequality grows to infinity more rapidly than the left hand side as $n\to+\infty$.

Then we choose that $n$, let $b=d_n+1$ and $c=(d_n+1)^2-a\cdot 10^n$. That gives us what we want. In fact, any larger $n$ also works, so there are infinitely many choices.

I used that technique to find the two cases given at the top of this answer.

0
On

There is a well-known algorithm for extracting the square root of a number. Treating your desired string of digits as an integer, add $1$, then use the standard square-root algorithm to compute the square root to a sufficient number of digits. The result (an approximate square root) is a decimal number whose square is the desired string of digits followed by some other digits. Multiply this approximate square root by a suitable power of $10$ so that the result is an integer. Now you have an integer whose square starts with the desired string of digits.

Full details and justification of the algorithm can be found in an earlier answer to a related question.