Archive for perfect square

Le Monde puzzle [#1119]

Posted in Kids, R with tags , , , , on December 8, 2019 by xi'an

A digit puzzle as Le weekly Monde current mathematical puzzle that sounds close to some earlier versions:

Perfect squares are pairs (a²,b²) with the same number of digits such that a²b² is itself a square. What is the pair providing a²b² less than 10⁶? Is there a solution with both integers enjoying ten digits?

The run of a brute force R code like

cek<-function(a,b){
  u<-trunc
  if ((n<-u(log(a^2,ba=10)))==u(log(b^2,ba=10))&
      (u(sqrt(a^2*10^(n+1)+b^2))^2==(a^2*10^(n+1)+b^2))) print(c(a,b))}

provides solutions to the first question.

[1] 2 3
[1] 4 9
[1] 12 20
[1] 15 25
[1] 18 30
[1] 49 99
[1] 126 155
[1] 154 300
[1] 159 281
[1] 177 277
[1] 228 100
[1] 252 310
[1] 285 125

with the (demonstrable) conclusion that the only pairs with an even number of digits are of the form (49…9²,9…9²), as for instance (49999²,99999²) with ten digits each.

Le Monde puzzle [#1114]

Posted in Kids, R with tags , , , , , , on October 16, 2019 by xi'an

Another very low-key arithmetic problem as Le Monde current mathematical puzzle:

32761 is 181² and the difference of two cubes, which ones? And 181=9²+10², the sum of two consecutive integers. Is this a general rule, i.e. the root z of a perfect square that is the difference of two cubes is always the sum of two consecutive integers squared?

The solution proceeds by a very dumb R search of cubes, leading to

34761=105³-104³

The general rule can be failed by a single counter-example. Running

sol=0;while(!sol){
  x=sample(2:1e3,1)
  y=sample(1:x,1)-1
  sol=is.sqr(z<-x^3-y^3)
  z=round(sqrt(z))
  if (sol) 
   sol=(trunc(sqrt(z/2))^2+ceiling(sqrt(z/2))^2!=z)}

which is based on the fact that, if z is the sum of two consecutive integers squared, a² and (a+1)² then

2 a²<z<2 (a+1)²

Running the R code produces

x=14, y=7

as a counter-example. (Note that, however, if the difference of cubes of two consecutive integers is a square, then this square can be written as the sum of the squares of two different integers.) Reading the solution in the following issue led me to realise I had missed the consecutive in the statement of the puzzle!

Le Monde puzzle [#1045]

Posted in Books, Kids with tags , , , , , , on May 13, 2018 by xi'an

An minor arithmetic Le Monde mathematical puzzle:

Take a sequence of 16  integers with 4 digits each, separated by 2,  such that it contains a perfect square and its sum is a perfect cube. What are the possible squares and cubes?

The question is dead easy to code in R

for (x in as.integer(1e3:(1e4-16))){
  if (max(round(sqrt(x+2*(0:15)))^2==x+2*(0:15))==1) {
    b=sqrt((x+2*(0:15))[round(sqrt(x+2*(0:15)))^2==x+2*(0:15)])
  if ((round((2*x+30)^(1/3)))^3==(2*x+30)) 
   print(c(x,b,(16*(x+15))^(1/3)))}}

and return the following solutions:

[1] 1357   37   28
[1] 5309   73   44

Nothing that exciting…!

Le Monde puzzle [#944]

Posted in Books, Kids, pictures, Statistics, Travel, University life with tags , , , , on January 20, 2016 by xi'an

A completely dull Le Monde mathematical puzzle:

Find all integer pairs (a,b) less than 10⁶ such that a-b=2015 and ab is a perfect square.

If  I write the only condition as the function

perfect=function(c){
  return(c==trunc(sqrt(c))^2)}

and brute-force checked for all possible solutions

for (A in 2015:1e6)
 if (perfect(A*(A-2015))) print(A)
trunc(y/10)*11+(y-10*trunc(y/10))-(y==10*trunc(y/10))}

which produced

[1] 2015
[1] 2304
[1] 2420
[1] 2511
[1] 3627
[1] 4212
[1] 7056
[1] 7595
[1] 16640
[1] 33759
[1] 41616
[1] 79092
[1] 204020

as the 13 possible answers. If one checks between 10⁶ and 5 10⁶, the only remaining solution is 1,016,064. Which is the highest possible one according to Le Monde.

Le Monde puzzle [#919]

Posted in Books, Kids, Statistics, University life with tags , , , , on July 19, 2015 by xi'an

A rather straightforward Le Monde mathematical puzzle:

Find 3 digit integers x such that the integer created by collating x with (x+1) gives a 6 digit integer that is a perfect square.

Easy once you rewrite the constraint as 1000x+x+1 being a perfect square a², which means that x is equal to (a-1)(a+1)/1001, hence that 1001=7x11x13 divides either a+1 or a=1.

sol=NULL
vals=as.vector(outer(c(7,11,13),1:999,"*"))
vals=c(vals-1,vals+1)
for (a in vals){
  x=round((a-1)*(a+1)/1001)
  if ((1000*x+x+1==a^2)&(x<999)&(x>99)) sol=c(sol,x)}

which returns four solutions:

> unique(sol)
[1] 183 328 528 715

An addendum to the puzzle is

Find 4 digit integers x such that the integer created by collating x with (x+1) gives an 8 digit integrer that is a perfect square.

Similarly easy once you rewrite the constraint as 10,000x+x+1 being a perfect square a², which means that x is equal to (a-1)(a+1)/10,001, hence that 10,001=73×137 divides either a+1 or a=1.

sol=NULL
vals=as.vector(outer(c(73,137),(1:9999),"*"))
vals=c(vals-1,vals+1)
for (a in vals){
  x=round((a-1)*(a+1)/10001)
  if ((10000*x+x+1==a^2)&(x<9999)&(x>999)) sol=c(sol,x)}

leading to the conclusion there is a single solution:

> unique(sol)
[1] 6099