Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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)- trunc(x/20)-trunc( /44)),from=10,to=250,add=TRUE,n=500)
Filed under: R, Statistics Tagged: arithmetics, Le Monde, mathematical puzzle, number theory, Phoenix, R, Université Paris Dauphine, WSC 11
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.