## Le Monde puzzle [#1111]

**A**nother low-key arithmetic problem as Le Monde current mathematical puzzle:

Notice that there are 10 numbers less than, and prime with 11, 100 less than and prime with 101, 1000 less than, and prime with 1111? What is the smallest integer N such that the cardinal of the set of M<N prime with N is 10⁴? What is the smallest multiple of 1111 using only different digits? And what is the largest?

As it is indeed a case for brute force resolution as in the following R code

library(numbers) homanycoprim=function(n){ many=1 for (i in 2:(n-1)) many=many+coprime(i,n) return(many)} smallest=function(){ n=1e4 many=homanycoprim(n) while (many!=1e4) many=homanycoprim(n<-n+1) return(n)}

which returns n=10291 as the smallest value of N. For the other two questions, the usual integer2digit function is necessary

smalldiff=function(){ n=1111;mul=1 while (mul<1e6) { x=as.numeric(strsplit(as.character(n*mul), "")[[1]]) while (sum(duplicated(x))!=0){ mul=mul+1 x=as.numeric(strsplit(as.character(n*mul), "")[[1]])} print(n*mul);mul=mul+1}}

leading to 241,087 as the smallest and 9,875,612,340 as the largest (with 10 digits).

September 19, 2019 at 8:11 am

[…] article was first published on R – Xi'an's Og, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here) […]

September 18, 2019 at 10:30 am

[…] by data_admin [This article was first published on R – Xi’an’s Og, and kindly contributed to R-bloggers]. (You can report issue about the content on this page […]