Three pirates an their monkey split a chest of gold coins.
First, the captain makes three equal piles, giving a single leftover coin to the monkey. He takes one of the piles for himself and pours the other two piles back in the treasure chest. The second-in-command does the exact same, followed by the swabbie also doing the exact same. Finally, the last of the gold in the chest is split equally between the three pirates.
How few coins could have been in the chest?
The individual actions of the three pirates onto the treasure chest are the same operation: from the starting amount in the chest subtract 1 and then multiply by 2/3. Expressed mathematically t(n) = (2/3) * (t(n-1) - 1)
We want to find some t(0) so we can apply this three times and stay in the domain of integers. For now allow negative integers.
The simplest possible answer is for the function to return the same value as it started, then t = (2/3) * (t - 1). This makes t=-2.
Now just to get back into the positive integers. For any given t(0) we can add any multiple of 3^3=27 and applying the operation three times will stay an integer:
t(0) = 27k-2 -> t(1) = 18k-2 -> t(2) = 12k-2 -> t(3) = 8k-2
So at this point we know the original contents of the chest is of the form 27k-2, and we have yet to address the last sentence. Thus we want the smallest k such that 8k-2 is positive and a multiple of 3.
Conveniently the first option k=1 fits, as 8*1-2 = 3*2 > 0. The chest originally had 27*1-2=25 coins.
If we were to go further then k=3j+1 gets us to generalized answer of 27*j+25 coins for integer j>=0.