# Why do repeating 8's show up more often in these decimals of square roots?

I was watching a video earlier today discussing irrational numbers, and one of their defining properties is the non-repeating decimal expansions. I decided to analyze some irrational numbers (in this case, square roots of integers, ignoring squares), and see when repeating numbers first appear.

For this simple case, I am just looking at the tenths place and seeing if it continues off to the right, thus providing a "false" hope that the square root is rational. When I pulled this up in Excel, certainly not the most elegant way, I found that the square root of 43 was the first to have 2 repeating digits (6.557), square root of 79 for 3 repeating digits (8.888), square root of 5168 for 4 repeating digits (71.8888), and square root of 492648 for 5 repeating digits (701.88888).

My main question is why the repeating 8's seem to be more common than other repeating decimals like .22222 or .33333. I can understand why .00000 or 0.99999 are fairly rare, because those are extremely close to an integer value, but for the other values I'm struggling to provide a rationale. Is it that my numbers I'm looking at (under the square root of 5,000,000) are just simply too small to be representative? Or is the fact I'm only considering decimals that have one number repeating, rather than many (like 190.514514....) the culprit?

• I wonder if this question is Pell-adjacent? Commented Aug 3 at 4:41
• There is also this. Not sure yours is a duplicate as it is more general than that question about a specific square root. I do suspect that the reason may be similar? Commented Aug 3 at 7:22
• For the square roots of the numbers from 1e8 to 2e8, I count .88888 only 1025 times and .66666 wins with 1381 times. Might be interesting to plot this to see how the "race" progresses... Commented Aug 3 at 20:02
• In 2e8 to 3e8, the counts are pretty even: 11111: 1060, 22222: 1060, 44444: 1060, 88888: 1060, 66666: 1059, 77777: 1059, 55555: 933, 33333: 436, 99999: 0 Commented Aug 3 at 20:12
• The leaders really change a lot. In 3e7 to 4e7 I just saw that .11111 led by far (other than .00000). Code, click "Execute" and wait four seconds. Commented Aug 3 at 20:26

(Edit: I've added in more details below.)

Nice question! The condition that $$\sqrt{n}$$ has a repeating digit of $$d$$ that repeats $$k$$ times after the decimal point is equivalent to the condition that

$$\sqrt{n} - m - \frac{d}{9} \frac{10^k - 1}{10^k}$$

is positive but less than $$10^{-k}$$, where $$m = \lfloor \sqrt{n} \rfloor$$ is the integer part. To get a rough idea of how this condition works we are going to simplify and replace that third term with $$\frac{d}{9}$$. So, let's write

$$\sqrt{n} = m + \frac{d}{9} + \varepsilon$$

where $$\varepsilon$$ is small. Squaring this gives

$$n = \left( m + \frac{d}{9} \right)^2 + 2 \left( m + \frac{d}{9} \right) \varepsilon + \varepsilon^2.$$

Since $$\varepsilon$$ is small this means that $$n$$ is close to $$\left( m + \frac{d}{9} \right)^2$$, so $$\left( m + \frac{d}{9} \right)^2$$ has to be close to an integer. For example, taking $$n = 5168$$ we have $$m = 71, d = 8$$ and

$$\left( m + \frac{d}{9} \right)^2 = \left( 71 + \frac{8}{9} \right)^2 = 5168.0\color{red}{123 \dots }.$$

It's a little easier to see why this happens if we rewrite it as

$$\left( 72 - \frac{1}{9} \right)^2 = 72^2 - 12 + \frac{1}{81}$$

where $$\frac{1}{81} = 0.0123 \dots$$. Note that this calculation works out nicely because $$72$$ is divisible by $$9$$. The same thing happens with your example of $$n = 492648, m = 701$$, which corresponds to

$$\left( 701 + \frac{8}{9} \right)^2 = \left( 702 - \frac{1}{9} \right)^2 = 702^2 - 2 \cdot 78 + \frac{1}{81}.$$

So we see that taking $$d = 8$$ and $$m + 1$$ to be divisible by $$9$$ produces a value of $$\left( m + \frac{d}{9} \right)^2$$ which is exactly $$\frac{1}{81}$$ larger than an integer. Since the distance to the closest integer has to be a multiple of $$\frac{1}{81}$$, this is the closest we can get, and using any other digit would be worse (or the same); for example if we tried $$d = 7$$ we'd get something like

$$\left( 72 - \frac{2}{9} \right)^2 = 72^2 - 24 + \frac{4}{81}$$

which is $$4$$ times worse!

The example $$n = 43, d = 5$$ actually behaves a little differently from these larger examples because $$m + 1$$ isn't divisible by $$9$$. Here the relevant calculation is instead

$$\left( 6 + \frac{5}{9} \right)^2 = 36 + \frac{20}{3} + \frac{25}{81} = 42 - \frac{2}{81}.$$

So here the middle term is not an integer but it partially cancels nicely with the last term to get a distance of $$\frac{2}{81}$$ to the nearest integer, which is pretty good but still not as good as $$\frac{1}{81}$$.

By working a little harder we can explicitly construct minimal examples with more repeating $$8$$s. So let's assume we're in the nice case above, $$d = 8$$ and $$m + 1$$ is divisible by $$9$$, so we can write $$m + 1 = 9 \ell$$. It turns out that to get accurate answers here we have to undo the simplification we did above and go back to considering $$\frac{d}{9} \frac{10^k - 1}{10^k} = \frac{d}{9} - \frac{d}{9 \cdot 10^k}$$. So, we are now considering

\begin{align*} n &= \left( 9 \ell - \frac{1}{9} - \frac{8}{9 \cdot 10^k} + \varepsilon \right)^2 \\ &\approx \left( 9 \ell - \frac{1}{9} \right)^2 - 2 \left( 9 \ell - \frac{1}{9} \right) \left( \frac{8}{9 \cdot 10^k} - \varepsilon \right) \end{align*}

where we've grouped the small terms together and ignored their square (which is really small). As we saw above, $$\left( 9 \ell - \frac{1}{9} \right)^2 = n + \frac{1}{81}$$, so subtracting gives

$$\frac{8}{9 \cdot 10^k} - \varepsilon \approx \frac{1}{162 \left( 9 \ell - \frac{1}{9} \right)}.$$

To find the smallest value of $$\ell$$ such that we get $$k$$ repeating $$8$$s we want to find the smallest value of $$\ell$$ such that $$0 < \varepsilon < 10^{-k}$$. For the smallest value of $$\ell$$ it turns out that $$\varepsilon$$ is very small, so we can compute $$\ell$$ by plugging in $$\varepsilon = 0$$ and solving for $$\ell$$, then rounding up, which gives (after some algebra)

$$\boxed{ \ell = \left\lceil \frac{10^k}{8 \cdot 162} + \frac{1}{81} \right\rceil }.$$

(That $$\frac{1}{81}$$ bit probably doesn't matter, at least for small $$k$$, but let's keep it to be safe.) Let's test this out: plugging in $$k = 4$$ gives $$\ell = 8$$, which reproduces $$m = 71, n = 5168$$. Plugging in $$k = 5$$ gives $$\ell = 78$$, which reproduces $$m = 701, n = 492648$$.

Now to find the next term! Plugging in $$k = 6$$ gives $$\ell = 772$$, which produces the new $$m = 6947, n = 48273160$$, with square root

$$\boxed{ \sqrt{n} = 6947.\color{red}{888888}000 \dots }.$$

Edit: The first half of the discussion above was incomplete; we didn't really rule out the possibility that other repeating digits could also occur first, and in particular we didn't rule out the possibility of $$d = 1$$ even though $$\left( 9 \ell + \frac{1}{9} \right)^2$$ is also exactly $$\frac{1}{81}$$ larger than an integer. Fortunately the more precise second half of the discussion gives us the tools to understand why $$d = 1$$ does not occur earlier than $$d = 8$$ (and the other digits should be similar). If we take $$d = 1, m = 9 \ell$$ then we are now considering

\begin{align*} n &= \left( 9 \ell + \frac{1}{9} - \frac{1}{9 \cdot 10^k} + \varepsilon \right)^2 \\ &\approx \left( 9 \ell + \frac{1}{9} \right)^2 - 2 \left( 9 \ell + \frac{1}{9} \right) \left( \frac{1}{9 \cdot 10^k} - \varepsilon \right) \end{align*}

and chasing through the same calculations as above produces

$$\ell = \left\lceil \frac{10^k}{162} - \frac{1}{81} \right\rceil.$$

So we can see what's gone wrong: the value of $$\ell$$ in this case is about $$8$$ times larger than when $$d = 8$$. For example taking $$k = 4$$ gives $$\ell = 62$$ which corresponds to $$m = 558, n = 311488$$ with square root

$$\sqrt{311488} = 558.\color{red}{1111}000 \dots.$$

Probably there's a better way of doing this calculation that works uniformly in the digit $$d$$ and explains more clearly where this factor of $$8$$ comes from, right now it's not quite intuitive to me yet.

• Hmm, the first half of this argument is actually very incomplete; the key thing we have to show is that choosing another digit makes the smallest value of $n$ larger and we haven't shown that. We particularly haven't ruled out the digit $d = 1$. But I think the second half of the argument suggests how this goes; we should get a similar expression for $\ell$ but with a smaller denominator. Commented Aug 3 at 8:04
• Brilliant! I’m wondering if constructing other irrationals based off of different kinds of roots (cube roots, 4th roots, etc.) would complicate this pattern Commented Aug 3 at 17:02
• @legofan779: cube roots are special here because they play well with all the $9$s that occur in our calculations above; for example $\sqrt[3]{19441} = 26.\color{red}{88888}95 \dots$ can be constructed with a similar idea as above, namely $19441 = \left( 27 - \frac{1}{9} \right)^3 + \frac{1}{9^3}$. For higher roots roughly the same basic idea should continue to work but there are more terms in the binomial expansion and analyzing it in detail gets more complicated. Commented Aug 3 at 18:09
• We also have $\sqrt[3]{19927} = 27.\color{red}{11111}05 \dots$ similarly, from $19927 = \left( 27 + \frac{1}{9} \right)^3 - \frac{1}{9^3}$. So I guess repeating $1$s are not so bad in this case. Commented Aug 3 at 18:13
• 1/9=0.111111... so 1-1/9=1-0.111111...=0.88888,,,, Commented Aug 4 at 2:47