
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 = the original number of bananas.
The first sailor divided them into 3 equal groups and had 1 banana left over.
. . . .[1]
He hid bananas and put the remaining bananas back in a pile.
The second sailor divided the bananas into 3 groups and had one left over.
. . . .[2]
He hid bananas and put the remaining bananas back in a pile.
The third sailor divided the bananas into 3 groups and one left over.
. . . .[3]
He hid bananas and put the remaining bananas back in a pile.
In the morning, they divided the bananas into 3 groups and had one left over.
. . . .[4]
From [4], we have: .
Substitute into [3]: .
Substitute into [2]: .
Substitute into [1]: .
So we have: .
Since is an integer, must be divisible by 8.
The first time this happens is when
Therefore: .

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