*This page concerns an unassuming little maths problem, which I decided to look into for a bit of fun. To my surprise, the question turned out to have an unexpected connection to a famous problem at the cutting edge of number theory, and necessitated a trip off into the numerical stratosphere in search of some fairly large solutions. The maths used here is probably about first year undergraduate level, and the style is certainly more technical than my previous article, so come prepared.*

While working on my follow up to the *Pointless* maths article, I became sidetracked by a nice little conundrum posted on Twitter:

Can a perfect square ever consist of the same string of digits written out twice (such as in 978978 or 46024602)? cc @jamestanton

— Matt Enlow (@CmonMattTHINK) December 4, 2014

This is exactly the sort of meaningless mathematical challenge that I enjoy, so let’s get stuck in.

Before we start, we need some notation. Let’s call the number that we are going to square *x* (we’re assuming that it’s a positive integer) and we’ll say that *x* has *d* digits. We want to find *x* such that *x*^{2} is equal to one of the twice-repeated string numbers described in the tweet.

First, let’s consider how large we should expect *x*^{2} to be, in terms of its number of digits. Since *x *has *d *digits, it satisfies the inequalities:

10^{d-1} ≤ *x* < 10^{d}

Since (10^{d-1})^{2} = 10^{2d-2}, which is the first integer with 2*d*-1 digits, and (10^{d})^{2} = 10^{2d}, which is the first integer with 2*d*+1 digits, *x*^{2} must have 2*d*-1 or 2*d* digits. Moreover, if *x*^{2} is to have a twice-repeated string of digits, as we wish, then it must have an even number of digits. Therefore, if we are able to find a solution *x* to our problem with *d* digits, then *x*^{2} will have to have 2*d* digits. This means that the string that will be repeated will have *d* digits, the same number as in *x*.

Now let’s think a little more about these numbers with repeating digits that we are interested in. For example, consider the number 345345. This number can be split up in the following way:

345345 = 345×10^{3 }+ 345 = 345 (10^{3} + 1)

Any such twice-repeated string number can be rewritten in this way. If we let *z* be the complete repeating number and *y *be the number formed by the string that is repeated (e.g. *z* = 345345 and *y* = 345 in the above example) and if *d* is the number of digits of *y*, then we can write:

*z* = *y* (10* ^{d}* + 1)

This allows us to state our original problem symbolically. We wish to find a positive integer *x*, with *d* digits, such that:

* x*^{2} = *y* (10* ^{d}* + 1)

**[Equation 1]**

for some positive integer *y*, which must also have *d* digits. If we can find such numbers, then we are done, because the left hand side will definitely be a perfect square and the right hand side will definitely be a twice-repeating string number. However, it may turn out that no such numbers exist, in which case we would like to find a rigorous proof that the problem is impossible so that we can all stop worrying about it and sleep easily in our beds.*

Let’s suppose that a solution does exist and try to work out what it would look like. Note in particular that 10* ^{d}* + 1 has

*d*+ 1 digits, so it must be larger than

*x.*Hold on to that thought, because in a minute it will prove to be a

**crucially important fact**.

The fundamental theorem of arithmetic tells us that every whole number can be expressed as a unique product of primes, so let’s write 10* ^{d}* + 1 in this way:

10* ^{d}* + 1 =

*p*

_{1}

^{a1}

*p*

_{2}

^{a2}…

*p*

_{n}

^{an}

Here, *p*_{1} , *p*_{2} , … , *p*_{n} are distinct primes, each raised to some positive integer power

*a*_{1} , *a*_{2} , … , *a*_{n} . Incidentally, we know that the smallest of these primes is at least 7, because it is quite easy to show that 10* ^{d}* + 1 is not divisible by 2, 3 or 5.

Now, Euclid’s Lemma tells us that if a prime number divides a product of two numbers then it must divide one or both of these numbers. Here then, we have that each of the primes

*p*_{1} , *p*_{2} , … , *p*_{n} divides 10* ^{d}* + 1, and from

**Equation 1**we see that 10

*+ 1 divides*

^{d}*x*

^{2}. Therefore all of the primes

*p*

_{1},

*p*

_{2}, … ,

*p*

_{n}divide

*x*

^{2}, which is the product of

*x*and

*x*. Therefore, all of the primes

*p*

_{1},

*p*

_{2}, … ,

*p*

_{n}divide

*x*, so

*x*=

*w*

*p*

_{1}

*p*

_{2}…

*p*

_{n}for some positive integer

*w*.

Suppose for a moment that every one of these primes appeared only once in the prime factorisation of 10* ^{d}* + 1. In other words,

*a*

_{1}=

*a*

_{2}= … =

*a*

_{n}= 1 and we can write

10

*+ 1 =*

^{d}*p*

_{1}

*p*

_{2}…

*p*

_{n}. This would mean that

*x*=

*w*(10

*+ 1), but since*

^{d}*w*is positive, this implies that

*x*≥ 10

*+ 1. However, the*

^{d}**crucially important fact**that we flagged up earlier told us that actually 10

*+ 1 >*

^{d}*x*. We therefore have a contradiction and so, if we have a solution, at least one of the primes in the factorisation of 10

*+ 1 must appear twice or more.*

^{d}At this point, we can take a breather from the heavy analysis to investigate some actual numbers of the form 10* ^{d}* + 1, to see what their prime factorisations actually look like. These numbers are simply those that start and end with a 1, with 0s in between. Here are the first few of them, with their prime factorisations (which I got from here):

- 10
^{1}+ 1 = 11**(prime)** - 10
^{2}+ 1 = 101**(prime)** - 10
^{3}+ 1 = 1001 = 7 × 11 × 13 - 10
^{4}+ 1 = 10001 = 73 × 137 - 10
^{5}+ 1 = 100001 = 11 × 9091 - 10
^{6}+ 1 = 1000001 =101 × 9901

- 10
^{7}+ 1 = 10000001 =11 × 909091

- 10
^{8}+ 1 = 100000001 =17 × 5882353

- 10
^{9}+ 1 = 1000000001 = 7 × 11 × 13 × 19 × 52579

- 10
^{10}+ 1 = 10000000001 = 101 × 3541 × 27961

- 10
^{11}+ 1 = 100000000001 =**11**× 23 × 4093 × 8779^{2}

Finally, we have arrived at a number of the form 10* ^{d}* + 1 with a repeated prime factor, which is what we were looking for. I am quite surprised that it took so long, and it would be interesting to know whether there is a particular reason why these numbers seem to have so few repeated prime factors. Things don’t get any better in this respect either, since you have to wait until

10

^{21}+ 1 = 1000000000000000000001 =

**7**× 11 × 13 × 127 × 2689 × 459691 × 909091 for the next one.**

^{2}Anyway, the repeated factor of 11 in 10^{11} + 1 gives us hope, since it suggests that we might be able to find some 11 digit solutions for *x*. We know that such an *x* must be divisible by all the distinct prime factors of 10^{11} + 1, so *x* will have to be a multiple of 11 × 23 × 4093 × 8779, which is equal to 9090909091. The first few multiples of this number provide us with the following “near misses”:

- 9090909091
^{2}=**826446281**00**826446281** - 18181818182
^{2}=**3305785124**0**3305785124** - 27272727273
^{2}=**7438016529**0**7438016529**

Note that these examples fail because the corresponding value of *y* (from **Equation 1**), the string of repeated numbers, has fewer than 11 digits, rendering our analysis invalid. However, the next seven multiples of 9090909091 all provide solutions to our problem:

- 36363636364
^{2}=**1322314049613223140496** - 45454545455
^{2}=**2066115702520661157025** - 54545454546
^{2}=**2975206611629752066116** - 63636363637
^{2}=**4049586776940495867769** - 72727272728
^{2}=**5289256198452892561984** - 81818181819
^{2}=**6694214876166942148761** - 90909090910
^{2}=**8264462810082644628100**

At this point, we run out of 11 digit solutions, as *x* and the corresponding *y* both tip over into twelve digits (in fact both *x* and *y* become equal to 10^{11} + 1) and our method stops working:

- 100000000001
^{2}= 10000000000200000000001

As we have already mentioned, we have to wait a long time for the next solutions to turn up, some 21-digit monsters. They are all multiples of 142857142857142857143, a number which rather beautifully contains three (and a bit) repetitions of the recurring part of the decimal expansion of 1/7 (looking back at our earlier solutions, they were clearly related to the decimal expansion of 1/11). This time there are only four solutions before the method breaks down, but they are rather lovely ones, borrowing the property of the decimal expansion of 1/7, whereby they are all (sort of) translated versions of one another (with the exception of the final digit in each case):

- 428571428571428571429
^{2}=**183673469387755102041183673469387755102041** - 571428571428571428572
^{2}=**326530612244897959184326530612244897959184** - 714285714285714285715
^{2}=**510204081632653061225510204081632653061225** - 857142857142857142858
^{2}=**734693877551020408164734693877551020408164**

Given how we derived these numbers, it is not too surprising that they are related to the decimal expansion of 1/7, since the number 142857142857142857143, of which these solutions are multiples, was derived by dividing the excess factor of 7 out of 1000000000000000000001. Nevertheless, it is quite an attractive and striking observation.

It would be interesting to look into these solutions and how frequently they occur in more depth, but, given that they seem to be tied in with a particularly mysterious unsolved*** problem in number theory (see the footnotes), I think pursuing this any further would likely drive me completely mad. Aside from anything else, there are practical difficulties when working with such big numbers. I looked for solutions with up to 29 digits, by checking the factorisations of 10* ^{d}* + 1 for repeated primes, but the online factoring calculator couldn’t go any higher than that. I believe, therefore, that the

**eleven solutions**on this page (seven with 11 digits, four with 21 digits) are the only solutions for which the number to be squared is less than 10

^{29 }(one hundred thousand trillion trillion, or one hundred

**octillion). That means that there are only eleven perfect squares consisting of a twice repeated string of digits that are smaller than 10**

^{58}.

Let’s just finish by marvelling at the size of this number. There are *only eleven* perfect squares of this kind that are less than:

**10000000000000000000000000000000000000000000000000000000000**

or

** ten billion trillion trillion trillion trillion**

or

ten octodecillion

Nice problem.

**UPDATE (04/2015): **Using Wolfram Alpha and the Number Empire online factoriser, I was able to extend the search up to 126 digit squares, revealing further families of solutions, including:

Seven 66 digit squares:

- 363636363636363636363636363636364
^{2}=**132231404958677685950413223140496132231404958677685950413223140496** - 454545454545454545454545454545455
^{2}=**206611570247933884297520661157025206611570247933884297520661157025** - 545454545454545454545454545454546
^{2}=**297520661157024793388429752066116297520661157024793388429752066116** - 636363636363636363636363636363637
^{2}=**404958677685950413223140495867769404958677685950413223140495867769** - 727272727272727272727272727272728
^{2}=**528925619834710743801652892561984528925619834710743801652892561984** - 818181818181818181818181818181819
^{2}=**669421487603305785123966942148761669421487603305785123966942148761** - 909090909090909090909090909090910
^{2}=**826446280991735537190082644628100826446280991735537190082644628100**

Eight 78 digit squares:

- 384615384615384615384615384615384615385
^{2}=**147928994082840236686390532544378698225147928994082840236686390532544378698225** - 461538461538461538461538461538461538462
^{2}=**213017751479289940828402366863905325444213017751479289940828402366863905325444** - 538461538461538461538461538461538461539
^{2}=**289940828402366863905325443786982248521289940828402366863905325443786982248521** - 615384615384615384615384615384615384616
^{2}=**378698224852071005917159763313609467456378698224852071005917159763313609467456** - 692307692307692307692307692307692307693
^{2}=**479289940828402366863905325443786982249479289940828402366863905325443786982249** - 769230769230769230769230769230769230770
^{2}=**591715976331360946745562130177514792900591715976331360946745562130177514792900** - 846153846153846153846153846153846153847
^{2}=**715976331360946745562130177514792899409715976331360946745562130177514792899409** - 923076923076923076923076923076923076924
^{2}=**852071005917159763313609467455621301776852071005917159763313609467455621301776**

There are a further seven 110 digit solutions and four 126 digit solutions, but let’s draw the line at 100 digits. Attempts to find even larger squares were thwarted by an inability to factorise 10^{64} + 1 (and by the fact that you have to stop somewhere!).

Together with the eleven solutions that we had already found, this allows to replace our earlier conclusion with the eminently more satisfying statement:

**There are only ***twenty-six* perfect squares of this kind smaller than a googol.

*twenty-six*perfect squares of this kind smaller than a googol.

* If we are really unlucky, it may turn out to be impossible to find a solution *and* impossible to prove that no solution exists (see Gödel’s Incompleteness Theorems), but we would have had to have kicked a lot of black cats under a lot of ladders to fall prey to that one.

** Fascinatingly, I think that the reason that so few numbers of the form 10* ^{d}* + 1 seem to have repeated prime factors and, consequently, why there are so few solutions to this problem (or that the solutions are so very sparsely distributed, at any rate) may have something to do with the abc conjecture, which I was aware of, but had never actually bumped into ‘in the wild’ before.

Very loosely (and I’m no expert on this), the abc conjecture says that, given coprime positive integers *a*, *b*, *c*, such that *a* + *b* = *c *, *c* tends not to exceed the product of all the distinct prime factors of *a*, *b*, *c* by too much (in the sense that there are only a finite number of triples *a*, *b*, *c* for which *c* exceeds this product by a certain degree). As I understand it, this (sort of) has the effect of preventing the prime factors of *c* from being raised to high powers in its prime decomposition, since this would illegally push up *c* relative to the aforementioned product.

The expression 10* ^{d}* + 1 =

*C*appears to be an example of the abc conjecture in action. The three terms are certainly coprime and as

*d*increases, so does

*C*. The effect, based on the abc conjecture, seems to be that the powers of the primes in the factorisation of

*C*must remain low, to prevent

*C*from excessively exceeding the product of its distinct prime factors with the 2 and 5 from the 10

*term.*

^{d}I certainly had no idea when I was starting out that the problem would be related to this result, so I really find this quite amazing!

*** Unless you are an expert in Inter-universal Teichmüller Theory of course.

Thomas Oléron Evans, 2014

Click here for the previous page in the Maths section.

Click here for the next page in the Maths section.

Matt ESo glad you derived so much fun from this problem! Cheers!