## Le Monde puzzle [#902] Another arithmetics Le Monde mathematical puzzle:

From the set of the integers between 1 and 15, is it possible to partition it in such a way that the product of the terms in the first set is equal to the sum of the members of the second set? can this be generalised to an arbitrary set {1,2,..,n}? What happens if instead we only consider the odd integers in those sets?.

I used brute force by looking at random for a solution,

```pb <- txtProgressBar(min = 0, max = 100, style = 3)
for (N in 5:100){
sol=FALSE
while (!sol){
k=sample(1:N,1,prob=(1:N)*(N-(1:N)))
pro=sample(1:N,k)
sol=(prod(pro)==sum((1:N)[-pro]))
}
setTxtProgressBar(pb, N)}
close(pb)
```

and while it took a while to run the R code, it eventually got out of the loop, meaning there was at least one solution for all n’s between 5 and 100. (It does not work for n=1,2,3,4, for obvious reasons.) For instance, when n=15, the integers in the product part are either 3,5,7, 1,7,14, or 1,9,11. Jean-Louis Fouley sent me an explanation:  when n is odd, n=2p+1, one solution is (1,p,2p), while when n is even, n=2p, one solution is (1,p-1,2p).

A side remark on the R code: thanks to a Cross Validated question by Paulo Marques, on which I thought I had commented on this blog, I learned about the progress bar function in R, setTxtProgressBar(), which makes running R code with loops much nicer!

For the second question, I just adapted the R code to exclude even integers:

```while (!sol){
k=1+trunc(sample(1:N,1)/2)
pro=sample(seq(1,N,by=2),k)
cum=(1:N)[-pro]
sol=(prod(pro)==sum(cum[cum%%2==1]))
}
```

and found a solution for n=15, namely 1,3,15 versus 5,7,9,11,13. However, there does not seem to be a solution for all n’s: I found solutions for n=15,21,23,31,39,41,47,49,55,59,63,71,75,79,87,95…

### 5 Responses to “Le Monde puzzle [#902]”

1. natesh Says:

seems likes a solution when n is prime or n = \prod p_i where
p_i are all distinct primes?

2. Dan Simpson Says:

setTxtProgressBar() is an excellent function! Thanks! So much better than my usual “let’s spit out integers” technique.

• xi'an Says:

Yes, as soon as I saw it, I adopted it! Note however that the counter is for the loop index and not for time!

• Robin Morris Says:

When I was a PhD student there were two sorts of programs in the lab. Those that counted, and those that printed dots on the screen…

• xi'an Says:

================================ 200%

This site uses Akismet to reduce spam. Learn how your comment data is processed.