1. ## Three sailors...

Three sailors were shipwrecked on an island. To make sure that they would
have enough to eat, they spent the day gathering bananas. They put the
bananas in a large pile and decided to divide the bananas equally among
themselves the next morning. However, each sailor distrusted the other
two, so after they were asleep, one of the sailors awoke and divided the
pile of bananas into three equal shares. When he did so, he found that he
had one banana left over; he fed it to a monkey. He then hid his share and
went back to sleep. A second sailor awoke and divided the remaining bananas
into three equal shares. He too found that he had one banana left over and
fed it to the monkey. He then hid his share and went back to sleep. The
third sailor awoke and divided the remaining bananas into three equal shares.
Again, one banana was left over, so he fed it to the monkey. He then hid his
share and went back to sleep. When the sailors got up the next morning, the
pile was noticeably smaller, but since they all felt guilty, none of them
said anything and they all agreed to divide the bananas. When they did so,
one banana was left over and they again gave it to the monkey.
What was the minimal possible number of bananas at the beginning?

2. Hello, mathcalculushelp!

This is a classic problem, usually called "The Monkey and the Coconuts";
. . often there are five or more sailors.

Let $N$ = the original number of bananas.

The first sailor divided them into 3 equal groups and had 1 banana left over.
. . . $N \;=\;3A + 1$ .[1]
He hid $A$ bananas and put the remaining $2A$ bananas back in a pile.

The second sailor divided the $2A$ bananas into 3 groups and had one left over.
. . . $2A \:=\:3B + 1$ .[2]
He hid $B$ bananas and put the remaining $2B$ bananas back in a pile.

The third sailor divided the $2B$ bananas into 3 groups and one left over.
. . . $2B \:=\:3C + 1$ .[3]
He hid $C$ bananas and put the remaining $2C$ bananas back in a pile.

In the morning, they divided the $2C$ bananas into 3 groups and had one left over.
. . . $2C \;=\;3D + 1$ .[4]

From [4], we have: . $C \:=\:\frac{3D+1}{2}$

Substitute into [3]: . $2B \;=\;3\left(\frac{3D+1}{2}\right)+1 \quad\Rightarrow\quad B \;=\;\frac{9D+5}{4}$

Substitute into [2]: . $2A \;=\;3\left(\frac{9D+5}{4}\right) + 1 \quad\Rightarrow\quad A \;=\;\frac{27D + 19}{8}$

Substitute into [1]: . $N \;=\;3\left(\frac{27D+19}{8}\right) + 1 \quad\Rightarrow\quad N \;=\;\frac{81D+65}{8}$

So we have: . $N \;=\;10D + 8 + \frac{D+1}{8}$

Since $N$ is an integer, $D+1$ must be divisible by 8.

The first time this happens is when $D = 7.$

Therefore: . $N \;=\;10(7) + 8 + \frac{7+1}{8} \quad\Rightarrow\quad \boxed{N \:=\:79}$

3. ## D+1?

I understood till N=(81D+65)/8

But where is the next step of D+1 coming from?

4. 81D + 65 = 80D + 64 + (D + 1). It's just an expansion making most of the terms divisible by 8. Dividing the expanded terms gives 10D + 8 + (D + 1)/8