
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?

Hello, mathcalculushelp!
This is a classic problem, usually called "The Monkey and the Coconuts";
. . often there are five or more sailors.
Let $\displaystyle N$ = the original number of bananas.
The first sailor divided them into 3 equal groups and had 1 banana left over.
. . . $\displaystyle N \;=\;3A + 1$ .[1]
He hid $\displaystyle A$ bananas and put the remaining $\displaystyle 2A$ bananas back in a pile.
The second sailor divided the $\displaystyle 2A$ bananas into 3 groups and had one left over.
. . . $\displaystyle 2A \:=\:3B + 1$ .[2]
He hid $\displaystyle B$ bananas and put the remaining $\displaystyle 2B$ bananas back in a pile.
The third sailor divided the $\displaystyle 2B$ bananas into 3 groups and one left over.
. . . $\displaystyle 2B \:=\:3C + 1$ .[3]
He hid $\displaystyle C$ bananas and put the remaining $\displaystyle 2C$ bananas back in a pile.
In the morning, they divided the $\displaystyle 2C$ bananas into 3 groups and had one left over.
. . . $\displaystyle 2C \;=\;3D + 1$ .[4]
From [4], we have: .$\displaystyle C \:=\:\frac{3D+1}{2}$
Substitute into [3]: .$\displaystyle 2B \;=\;3\left(\frac{3D+1}{2}\right)+1 \quad\Rightarrow\quad B \;=\;\frac{9D+5}{4}$
Substitute into [2]: .$\displaystyle 2A \;=\;3\left(\frac{9D+5}{4}\right) + 1 \quad\Rightarrow\quad A \;=\;\frac{27D + 19}{8}$
Substitute into [1]: .$\displaystyle N \;=\;3\left(\frac{27D+19}{8}\right) + 1 \quad\Rightarrow\quad N \;=\;\frac{81D+65}{8}$
So we have: .$\displaystyle N \;=\;10D + 8 + \frac{D+1}{8}$
Since $\displaystyle N$ is an integer, $\displaystyle D+1$ must be divisible by 8.
The first time this happens is when $\displaystyle D = 7.$
Therefore: .$\displaystyle N \;=\;10(7) + 8 + \frac{7+1}{8} \quad\Rightarrow\quad \boxed{N \:=\:79}$

D+1?
I understood till N=(81D+65)/8
But where is the next step of D+1 coming from?

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