**T**he current puzzle is… puzzling:

*Given the set {1,…,N} with N<61, one iterates the following procedure: take (x,y) within the set and replace the pair with the smallest divider of x+y (bar 1). What are the values of N such that the final value in the set is 61?*

**I** find it puzzling because the way the pairs are selected impacts the final value. Or not, depending upon *N*. Using the following code (with *factors()* from the *pracma* package):

library(pracma)
endof=function(N){
coll=1:N
for (t in 1:(N-1)){
pair=sample(1:length(coll),2)
dive=min(factors(sum(coll[pair])))
coll=coll[-pair]
coll=c(coll,dive)
}
print(dive)
}

I got:

> for (t in 1:10) endof(10)
[1] 5
[1] 3
[1] 3
[1] 5
[1] 7
[1] 5
[1] 5
[1] 7
[1] 3
[1] 3> for (t in 1:10) endof(16)
[1] 2
[1] 2
[1] 2
[1] 2
[1] 2
[1] 2
[1] 2
[1] 2
[1] 2
[1] 2

**F**or *N* of the form *4k* or *4k-1*, the final number is always 2 while for *N*‘s of the form *4k-2* and *4k-3*, the final number varies, sometimes producing 61′s. Although I could not find solutions for *N* less than 17… Looking more closely into the sequence leading to 61, I could not see a pattern, apart from producing prime numbers as, in, e.g.

61 = 2 + [12 + (4 + {14 + [13 + 16]})]

for *N*=17. (Another puzzle is that 61 plays no particular role: a long run of random calls to endof() return all prime numbers up to 79…)

**Udate:** Looking at the solution in today’s edition, there exist a solution for *N=13* and a solution for *N=14*. Even though my R code fails to spot it. Of course, an exhaustive search would be feasible in these two cases. (I had also eliminated values below as not summing up to 61.) The argument for eliminating 4k and 4k-1 is that there must be an odd number of odd numbers in the collection, otherwise, the final number is always 2.

Filed under: Books, Kids, R Tagged: factors(), Le Monde, mathematical puzzle, pracma, prime numbers, R

*Related*

To

**leave a comment** for the author, please follow the link and comment on his blog:

** Xi'an's Og » R**.

R-bloggers.com offers

**daily e-mail updates** about

R news and

tutorials on topics such as: visualization (

ggplot2,

Boxplots,

maps,

animation), programming (

RStudio,

Sweave,

LaTeX,

SQL,

Eclipse,

git,

hadoop,

Web Scraping) statistics (

regression,

PCA,

time series,

trading) and more...

If you got this far, why not

__subscribe for updates__ from the site? Choose your flavor:

e-mail,

twitter,

RSS, or

facebook...