# When written in decimal notation, every square number has at most 1000 digits that are not 0 or 1. True or false?

When written in decimal notation, every square number has at most $1000$ digits that are not $0$ or $1$. True or false?

This question is from an admissions quiz, so no calculators should be used.

• [silly]$2^2 = 3.9999999...$ have clearly more than 1000 nines, so it's false[/silly] Commented Nov 2, 2013 at 17:56

This is how I did it, but I'm sure there are better ways.

Let $x = 10^n - 1$ with $n\in\mathbb{Z}$, then $x^2 = 10^{2n} - 2\times10^n + 1 = 999\cdots9998000\cdots001$

Let $n>1001$ so we have more than $1000$ nines, then we've found a square number with more than $1000$ digits that are not $0$ or $1$, so it's false.

• This is the only part of your answer that I wholeheartedly disagree with: "... but I'm sure there are better ways."
– Doc
Commented Nov 2, 2013 at 7:08
• Brilliant. As long as you're familiar with arithmetic tricks like $99999^2=9999800001$, it doesn't take long to arrive at this counterargument. Commented Nov 2, 2013 at 13:14

This is so grossly false that I don't think it is worth constructing a very detailed counterexample. The ratio of successive squares $\frac{(n+1)^2}{n^2}$ decreases and tends to$~1$, so for any $\epsilon>0$ there is an (easily found) $~N\in\Bbb N$ such that $1<\frac{(n+1)^2}{n^2}<1+\epsilon$ for all $n\geq N$. Now take a number $m$ given by any sequence of digits that violates your condition ($1001$ digits $7$ will do) and find $N$ corresponding to $\epsilon=\frac1{10m}$. Now take $k\in\Bbb N$ sufficiently large so that $10^km>N^2$ and put $n=\lfloor\sqrt{10^km}\rfloor$ (one has $n\geq N$). Then one has $10^km<(n+1)^2<10^k(m+\frac1{10})$ so the number $(n+1)^2$ starts with the digits of $m$.

The same argument shows that any finite sequence of digits occurs (infinitely often) as the initial digit sequence of a square. It can also be adapted easily to many other kinds of numbers with a similar density.

$$(10^n+n)^2=10^{2n}+2n \cdot 10^n+n^2$$ So each even number can appear as pattern in a square number. If one chooses $n=5m$ then $2n=10m$ and so each $m \in \mathbb{N}$ appears as digit pattern in the above sequence.

• I like this a lot!!! Commented Nov 3, 2013 at 18:13

Here's the first thing I dug out of a cobweb covered corner in the old brain. Similar in spirit to that of Oliver's \begin{aligned} 35^2&=1225\\ 335^2&=112225\\ 3335^2&=11122225\\ \cdots&=\cdots \end{aligned} Here $x_n=333\ldots5=(10^n+5)/3$. Therefore $$x_n^2=\frac{10^{2n}+10^{n+1}+25}9.$$ The first $(n-1)$ digits of that are equal to those of $10^{2n}/9$, i.e. all ones. Similarly the next $n$ digits are all twos.

For $111\ldots11^2$ one can say something precise also. This problem shows that if the number of ones in the string of digits is $n=9q+r, 0\le r<9,$ then the some of the digits of the square is $81q+r^2$. As the number of digits in the square is about $2n\approx 18q$ the average digit has to be about $81/18=9/2$, and thus the number of non-$0/1$s grows without a bound.

Fix $n$. Let $x=\sum_{k=0}^n10^{kn}$. Then $x^2=\sum_{j=0}^{2n}\left(n-\left|n-j\right|+1\right)\,10^{nj}$. For example, with $n=3$ we have $$1001001001^2=1002003004003002001$$

$x^2$ contains the disjoint substrings $1$ through $n$ twice, and $n+1$ in the center. (The individual strings move farther apart separated by more and more $0$s too fast for two strings to interact additively.) So with large enough $n$, you can get any number of digits that are not $0$ or $1$. (Or additionally are not equal to $9$; although I like your answer, it does not extend if $9$ is added to the list of special digits.) A quick calculation suggests $n=271$ works for the situation described in the question. (Counting the duplication of each string, we've seen 2 through 9 in the ones place $54$ times for $432$ non-0, non-1 digits. We've seen 2 through 6 in the tens place $60$ times each, for $300$ more. 8 and 9 in the tens place $40$ times each, for $80$ more. 7 has been in the tens place $44$ times. And 2 has been in the hundreds place $144$ times. Now $432+300+80+44+144=1000$ non-0, non-1 digits, and this doesn't even count the 272 that's in the center.

I think you can get the same effect without letting the numbers grow so incredibly large with $x=\sum_{k=0}^n10^{k\lceil\log_{10}(n+2)\rceil}$. For example, with $n=3$ this gives

$$1111^2=1234321$$

and with $n=9$ this gives

$$1010101010101010101^2=1020304050607080910090807060504030201$$

The logarithm is determining how many zeros are minimally needed as buffers to prevent additive interaction. Again using $271$, then this method yields an $x$ with $813$ digits, compared to your $x$ that has 1000 digits.

I'm curious what the smallest $x$ is such that $x^2$ has over 1000 non-0, non-1 digits. My $x$ is an upper bound that's a little larger than $10^{813}$, and $10^{500}$ is a lower bound.