Three pirates land on an island where they find a buried treasure. They agree to open the treasure box divide the treasure evenly but first they
need a good night sleep. During the night, one pirate wakes up, opens
the box, puts one coin from the treasure box into his pocket, takes the
number of remaining coins and buries one-third of what's left in the
box, and then goes back to sleep. Then the second pirate awakens and
does the same thing as the first. Later, the third pirate wakes up and
also does the same. In the morning, there are fewer than 10 coins left
in the treasure box. Each pirate takes a number of the remaining coins
that is exactly one-third of what is left in the box.
How many coins were in the original treasure box?