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 0 0
 2 0 0
 3 0 0
 5 1 1
 6 1 1
 7 1 1
 10  2  2
 12  3  3
 13  3  3
 14  3  3
 16  4  4
 17  4  4
 18  4  4
 19  4  4
 20  4  4
 21  4  4
 24  5  5
 28  6  6
 29  6  6
 32  7  7
 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)-
Filed under: R, Statistics Tagged: arithmetics, Le Monde, mathematical puzzle, number theory, Phoenix, R, Université Paris Dauphine, WSC 11        