Chalenge
Three sailors were shipwrecked on a deserted island. The only life they
could observe on the island were birds and a monkey, and the only food
source seemed to be coconuts from the coconut trees. They agreed to pool
their efforts to gather the coconuts for food into one area and divide
the coconuts equally. After gathering the coconuts, the sailors were too
tired to eat and decided to sleep for the night and divide the pile of
coconuts in the morning. During the night one of the sailors awoke,
divided the pile of coconuts into three equal piles, but had one coconut
left over which he gave to the monkey watching him in puzzlement. Then
he hid one pile, put the other two piles back together, and went back to
sleep. A little later the second sailor awoke and did the same thing,
making three equal piles of coconuts and had one coconut left over which
he gave to the monkey, hiding his pile, returning to sleep. The third
sailor awoke and did exactly the same thing (he also had one coconut
left over which he gave the monkey, etc.). In the morning non of the
sailors would admit that the pile of coconuts looked smaller for fear of
incriminating themselves, and so they divided the remaining coconuts
equally into three piles, and had one left over which they gave to the
monkey. What is the smallest number of coconuts that could have been in
the original pile before any divisions were made?
For this program use only while loops and wPuts it out in a exw file for
win32.
|
Not Categorized, Please Help
|
|