This is a very old puzzle, and there are lots of web pages dealing with it; try it yourself as it's really tricky.
Five pirates are marooned on an island. They spend their first day going around the island collecting coconuts. At the end of the day they put all the coconuts in a pile and go to sleep, no doubt exhausted by their efforts!
During the night a pirate (let's call him Pirate 1) wakes up, and is worried about getting his share of the coconuts. So he splits the coconuts into five equal piles, and finds that there is one coconut left over. He gives the spare coconut to a passing monkey, hides his share of the coconuts, puts the remaining coconuts back into one pile, and goes to sleep.
Later in the night another pirate (let's call him Pirate 2) wakes up, and he too is worried about getting his share of the coconuts. So he splits the remaining coconuts into five equal piles, and finds that there is one coconut left over. He gives the spare coconut to a passing monkey, hides his share of the coconuts, puts the remaining coconuts back into one pile, and goes to sleep.
During the remainder of the night the other three pirates in turn, wake up, split the coconuts into five piles, give the spare coconut to the monkey, hide their share, restore the pile, and go back to sleep.
In the morning the five pirates wake up and decide to spilt the coconuts between them. They make five equal piles, and for the sixth time there is a spare coconut, which again goes to the monkey. The pirates all take their share and, presumably, add the coconuts to the ones that they stole during the night.
The question is, what is the smallest number of coconuts that were originally collected?
As stated above, there are many web pages that give the lengthy explanation of the maths behind this puzzle. The upshot being that the pirates collected 15,621 coconuts.
Pirate 1 split these into five piles of 3,124 coconuts, plus one for the monkey, hid 3,124 coconuts and left 12,496 coconuts behind.
Pirate 2 split these into five piles of 2,499 coconuts, plus one for the monkey, hid 2,499 coconuts and left 9,996 coconuts behind.
Pirate 3 split these into five piles of 1,999 coconuts, plus one for the monkey, hid 1,999 coconuts and left 7,996 coconuts behind.
Pirate 4 split these into five piles of 1,599 coconuts, plus one for the monkey, hid 1,599 coconuts and left 6,396 coconuts behind.
Pirate 5 split these into five piles of 1,279 coconuts, plus one for the monkey, hid 1,279 coconuts and left 5,116 coconuts behind.
In the morning the pirates split these into five piles of 1,023 coconuts, plus one for the monkey, and added 1,023 coconuts to their respective stashes.