**From New Scientist #1292, 11th February 1982** [link]

“Think of a two-digit number.”

“Right.”

“Call it *AB* for the moment. Now think of a one-digit number.”

“Right.”

“Call it *C*. Does *AB* + *C* make a two-digit number?”

“Yes, it does.”

“Call that one *DE*. Now write down the five-digit number *ABCDE* and divide it by 581. What do you get?”

“Well, *AB* was 45. *C* was 6 and so *DE* was 51. So my answer is 78.573149 or thereabouts.”

“Bad luck! If it had come out as a whole number, I would have paid for the drinks.”

What whole number would have done the trick?

This puzzle does not have a unique solution.

**Enigma 52** and **Enigma 262** are also called “Think of a number”.

[enigma147]

### Like this:

Like Loading...

This Python program examines all 5-digit multiples of 581 to find the solution. It runs in 35ms.

Solution:It is possible to end up with a whole number answer in two ways. You can arrive at 158 by choosing AB=91 and C=7, and this is the published solution. But by choosing AB=83 and C=0 (which is not disallowed by the problem statement) you can also get the answer of 143.Here is a different approach:

It does find the answer (and if you remove the assumption that C is non-zero it finds the second solution). But it also assumes that A, B and C are all different digits, which is the case in the answer, but it isn’t a requirement given in the puzzle statement.

(I’d also just use the

%operator to check for divisibility in line 10:and that would make the program work in Python 2 as well).

This solution finds both answers of 91798 and 83083;

I think the problem with using

itertools.permutations()is that it only looks at cases where the digits in AB and C are all different, which isn’t required by the problem statement. (Although it does turn out to be the case in the answer(s)).Instead you could use

itertools.product(), which would check 1000 possibilities for (A, B, C), rather than the 720 checked by usingitertools.permutations().