Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

After a loooong break, here is one Le Monde mathematical puzzle I had time to look at, prior to going to Dauphine for a Saturday morning class (in replacement of my R class this week)! The question is as follows:

A set of numbers {1,…,N} is such that multiples of 4 are tagged C and multiples of 5 and of 11 are tagged Q. Numbers that are not multiples of 4, 5, or 11, and numbers that are multiples of both 4 and 5 or of both 4 and 11 are not tagged. Find N such that the number of C tags is equal to the number of Q tags.

This is a plain enumeration problem.

N=0
noco=TRUE
nbC=nbQ=0

while (noco){
N=N+1
divF=FALSE
if (trunc(N/4)*4==N){
nbC=nbC+1
divF=TRUE
}
if ((trunc(N/5)*5==N)||(trunc(N/11)*11==N)){
if (divF){
nbC=nbC-1
}else{ nbQ=nbQ+1}
}
noco=(nbC!=nbQ)
}


When I ran the code, I found many solutions

[1] 1 0 0
[1] 2 0 0
[1] 3 0 0
[1] 5 1 1
[1] 6 1 1
[1] 7 1 1
[1] 10  2  2
[1] 12  3  3
[1] 13  3  3
[1] 14  3  3
[1] 16  4  4
[1] 17  4  4
[1] 18  4  4
[1] 19  4  4
[1] 20  4  4
[1] 21  4  4
[1] 24  5  5
[1] 28  6  6
[1] 29  6  6
[1] 32  7  7
[1] 64 12 12


with no value further than 64 (testing all the way to 3,500,000). This seems in line with the fact that there are more multiples of 5 or 11 than of 4 when N is large enough. This can be seen by drawing the curves of the (approximate) number of multiples:

curve((trunc(x/4)-trunc(x/20)-trunc(x/44)),
from=10,to=250,n=500)
curve((trunc(x/5)+trunc(x/11)-trunc(x/55)-