Le Monde puzzle [#814]

April 1, 2013

(This article was first published on Xi'an's Og » R, and kindly contributed to R-bloggers)

The #814 Le Monde math puzzle was to find 100 digits (between 1 and 10) such that their sum is equal to their product. Given the ten possible values of those digits, this is equivalent to finding integers a1,…,a10 such that




which reduces the number of unknowns from 100 to 10 (or even 9). Furthermore, the fact that the (first) sum of the ai‘s is less than 100 implies that the (second) sum of the iai‘s is less than 1000, hence iai is less than 1000. This reduces the number of possible ten-uplets enough to allow for an enumeration,  hence the following R code:


for (i2 in 0:bounds[2])
for (i3 in 0:bounds[3])
for (i4 in 0:bounds[4])
for (i5 in 0:bounds[5])
for (i6 in 0:bounds[6])
for (i7 in 0:bounds[7])
for (i8 in 0:bounds[8])
for (i9 in 0:bounds[9])
for (i10 in 0:bounds[10]){

  if (sum(A)<101){

   if (sum((1:10)*A)==prod((1:10)^A))

that produces two answers

 [1] 97  0  0  2  0  0  1  0  0  0
 [1] 95  2  3  0  0  0  0  0  0  0

i.e. either 97 1′s, 2 4′s and 1 7, or 95 1′s, 2 2′s and 3 3′s. I would actually love to see a coding solution that does not involve this pedestrian pile of “for”. And a mathematical solution based on Diophantine equations. Rather than the equally pedestrian solution given by Le Monde this weekend.

Filed under: Books, Kids, R Tagged: Diophantine equations, Le Monde, mathematical puzzle, R

To leave a comment for the author, please follow the link and comment on their blog: Xi'an's Og » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Mango solutions

plotly webpage

dominolab webpage

Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training





CRC R books series

Six Sigma Online Training

Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)