Le Monde puzzle [#939]

A Le Monde mathematical puzzle about special integers:

Find all integers with less than 11 digits that are perfect squares and can be written as a(a+6), a being an integer.

Eleven digits being too much for a brute force exploration of the form `for (t in 1:1e11)`…, some preliminary  analysis is needed, but I could not figure out a reason why there is no solution apart from 2… (I checked up to 1e8!)

Since I had “guessed” the above puzzle from the solution published one week later (!), I checked the quality of my guesswork with my friend Jean-Louis Fouley, who gave me the genuine question, based on a different interpretation of a(a+6):

Find all integers with less than 11 digits that are perfect squares and can be written as x concatenated with (x+6), x being an integer.

This is more open to brute-force R exploration (with some help from stack overflow) since x only has five digits at most!

[sourcecode language=”r” gutter=”false”]
perfect=function(b){
x=FALSE
a=trunc(sqrt(b))
for (i in a:(a+1))
if (i^2==b) x=TRUE
return(x)}

for (x in 1:(1e6-1))
if (perfect(
as.numeric(paste(c(as.numeric(strsplit(as.character(x), "")[[1]]),
as.numeric(strsplit(as.character(x+6), "")[[1]])),collapse=""))))
print(x)
[/sourcecode]

Which returns

[sourcecode language=”r” gutter=”false”]
[1] 15
[1] 38
[/sourcecode]

and then crashes for x=99994, because

[sourcecode language=”r” gutter=”false”]
strsplit(as.character(1e+05), "")
[/sourcecode]

does not return the six digits of 1e+05 but

[sourcecode language=”r” gutter=”false”]
[[1]]
[1] "1" "e" "+" "0" "5"
[/sourcecode]

instead. Except for this value of x, no other solution is found using this R code. And for x=99994, y=99994100000 is not a perfect square.

4 Responses to “Le Monde puzzle [#939]”

  1. Why only 2? Simple. You are looking for a solution of the type a(a+6)=y^2. So a^2+6a-y^2=0. For this to have an integer solution then sqrt(9+y^2) needs to be integer, and the only time this happens is when y=4, so y^2=16 and a=2.
    Algebra to the rescue!!

Leave a Reply

Discover more from Xi'an's Og

Subscribe now to keep reading and get access to the full archive.

Continue reading