# An algebraic riddle: The king's chest full of bags of gold coins

Consider following riddle in short form:

A king seeks a new treasurer and ask all the possible candidates the following question to check their logical abilities.

"There is a chest in front of you. The chest holds bags which contain the same amount of gold coins. The chest contains a total of coins between 150 and 200. The chest holds more than one bag and every bag holds more than one coin. If I'd tell you the total of coins in the chest, you'd be able to tell me how many bags the chest holds and how many coins each bag holds. How many coins are in the chest, how many coins are in each bag, and how many bags are in the chest?"

I've figured the answer out by using some kind of brute force of dividing the numbers between 150 and 200 to find the solution. But how would one solve this using algebra?

• how did you find the answer?, if total coins are $175=35*5=5*5*7$, how can we tell whether $5$ bags or $35$ bags or $25$ bags or $7$ bags? – Vikram Aug 18 '17 at 10:12
• I just checked the numbers between 150 and 200 which satisfy the condition $x%y=0, y<x$ and only give one solution. Which leads to $13^2$. – Bastian Aug 18 '17 at 10:52
• @Vikram Because the king specifically tells us that we WILL be able to deduce how many coins there are in each bag, so obviously, it's not 175. – Shufflepants Aug 18 '17 at 14:14
• The number of coins must be the square of a prime $p$. Therefore, $\sqrt 150 \le p \le \sqrt 200$ and $12 < p \le 14$ – saulspatz Aug 18 '17 at 18:33

## 2 Answers

Suppose there were $182$ coins. That could be $14×13$ or $26×7$, among other things. So we could not tell how many bags or how many coins per bag there are.

Suppose there were $187$ coins. That can only be $11×17$, the product of two primes. But which is $11$, the number of bags or the number of coins per bag?

To avoid these ambiguities, you need a number of coins that is the product of two identical primes, meaning it's the square of this common prime. There is only one such number between $150$ and $200$.

Apparently the king is not triskaidekaphobic ... .

Let's note $b$ the number of bags in the chest.

Let's note $c$ the number of coins in each bags.

Then we can easily deduce that the total number of coins $t$ in the chest is :

$$t = b*c$$

Furthermore we have $b>1,c>1$ as a condition.

Now the problem here is that if the King gives $t$ then we end up with one equation with two variables, meaning there can be multiple solutions :

For example, let say the King says "There is $180$ coins in the chest" which is $t=180$, now we end up with the following equation :

$$180 = b*c$$

For which there is multiple $(b,c)$ solutions :

$$(2,90),(3,60),(4,45), (5,36),(6,30),(9,20),(10,18),(12,15),(15,12),(18,10),(20,9,(30,6),(36,5),(45,4),(60,3),(90,2)$$

Here I chose $180$ to show there could be a lot of solutions.

There could also be no solution if the King says a prime number between $150$ and $200$, which are :

$$151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199$$

Because the number of bags and coins is an integer and any of those numbers cannot be the product of two integers greater than $1$, there is no solution for those numbers.

EDIT :

If I'd tell you the total of coins in the chest, you'd be able to tell me how >many bags the chest holds and how many coins each bag holds.

This means that the total number of coins gives a single $(b,c)$ solution. Which means :

• $b=c$, or else $(b,c)$ and $(c,b)$ are two different solutions.

• $b$ is a prime number, or else we could have more solutions.

Now with those clues and $t\in [150,200]$ we can deduce that :

$$t=169\text{ and } b=c=13$$