Le Monde puzzle [#6]

February 17, 2011
By

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

A simple challenge in Le Monde this week: find the group of four primes such that any sum of three terms in the group is prime and the overall sum is minimised. Here is a quick exploration by simulation, using the schoolmath package (with its imperfections):

```A=primes(start=1,end=53)[-1]
lengthA=length(A)

res=4*53
for (t in 1:10^4){

B=sample(A,4,prob=1/(1:lengthA))
sto=is.prim(sum(B[-1]))
for (j in 2:4)
sto=sto*is.prim(sum(B[-j]))

if ((sto)&(sum(B)
providing the solution 5 7 17 19.
A subsidiary question in the same puzzle is whether or not it is possible to find a group of five primes such that any sum of three terms is still prime. Running the above program with the proper substitutions of 4 by 5 does not produce any solution, even when increasing the upper boundary in A. So it is most likely that the answer is no.
Filed under: R, Statistics Tagged: bug, Le Monde, mathematical puzzle, prime numbers, schoolmath

var vglnk = { key: '949efb41171ac6ec1bf7f206d57e90b8' };

(function(d, t) {
var s = d.createElement(t); s.type = 'text/javascript'; s.async = true;
var r = d.getElementsByTagName(t)[0]; r.parentNode.insertBefore(s, r);
}(document, 'script'));

Related
ShareTweet

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.