## Le Monde puzzle [#967]

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

A Sudoku-like Le Monde mathematical puzzle for a come-back (now that it competes with The Riddler!):

Does there exist a 3×3 grid with different and positive integer entries such that the sum of rows, columns, and both diagonals is a prime number? If there exist such grids, find the grid with the minimal sum?

I first downloaded the R package primes. Then I checked if by any chance a small bound on the entries was sufficient:

```cale<-function(seqe){
ros=apply(seqe,1,sum)
cole=apply(seqe,2,sum)
dyag=sum(diag(seqe))
dayg=sum(diag(seqe[3:1,1:3]))
return(min(is_prime(c(ros,cole,dyag,dayg)))>0)}
```

Running the blind experiment

```for (t in 1:1e6){
n=sample(9:1e2,1)
if (cale(matrix(sample(n,9),3))) print(n)}
```

I got 10 as the minimal value of n. Trying with n=9 did not give any positive case. Running another blind experiment checking for the minimal sum led to the result

```> A
[,1] [,2] [,3]
[1,] 8 3 6
[2,] 1 5 7
[3,] 2 11 4
```

with sum 47.

## Le Monde puzzle [#913]

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

An arithmetics Le Monde mathematical puzzle:

Find all bi-twin integers, namely positive integers such that adding 2 to any of their dividers returns a prime number.

An easy puzzle, once the R libraries on prime number decomposition can be found!, since it is straightforward to check for solutions. Unfortunately, I could not install the recent numbers package. So I used instead the schoolmath R package. Despite its possible bugs. But it seems to do the job for this problem:

```lem=NULL
for (t in 1:1e4)
if (prod(is.prim(prime.factor(t)+2)==1))
lem=c(lem,t)digin=function(n){
```

which returned all solutions, albeit in a lengthy fashion:

```> lem
[1] 1 3 5 9 11 15 17 25 27 29 33 41 45 51 55
[16] 59 71 75 81 85 87 99 101 107 121 123 125 135 137 145
[31] 149 153 165 177 179 187 191 197 205 213 225 227 239 243 255
[46] 261 269 275 281 289 295 297 303 311 319 321 347 355 363 369
[61] 375 405 411 419 425 431 435 447 451 459 461 493 495 505 521
[76] 531 535 537 561 569 573 591 599 605 615 617 625 639 641 649
[91] 659 675 681 685 697 717 725 729 745 765 781 783 807 809 821
[106] 825 827 841 843 857 867 881 885 891 895 909 933 935 955 957
[121] 963 985 1003 1019 1025 1031 ...
```

## Le Monde puzzle [#29]

Posted in R, Statistics with tags , , on July 29, 2011 by xi'an

This week, the puzzle from the weekend edition of Le Monde was easy to state: in the sequence (8+17n), is there a 6th power? a 7th? an 8th? If so, give the first occurrence. So I first wrote an R code for a function testing whether an integer is any power:

```ispower=function(x){
ispo=FALSE
logx=log(x)
i=trunc(logx/log(2))
while((i>1)&&(!ispo)){
j=t=trunc(exp(logx/i))
while (t<x) t=j*t
ispo=(x==t)
if (!ispo){
j=t=j+1
while (t<x) t=j*t
ispo=(x==t)}
i=i-1}
list(is=ispo,pow=j)}
```

(The function returns the highest possible power.) Then I ran the thing over the first million of values of the sequence:

```fib=8
for (j in 1:10^6){
fib=fib+17
tes=ispower(fib)
if (tes\$is)
print(c(fib,tes\$pow,log(fib)/log(tes\$pow)))}
```

only to find that only the powers 2,3,6,10,11,19 were present among the first terms. Continue reading