This page presents a classic problem, specifically: "How many coconuts need to
be in a pile such that N consecutive persons can take away one (giving it to a monkey),
then divided the pile into exactly Q equal portions, take away P of those portions
leaving a new pile for the next person?" If there were an N+1 person, either
there would be only 1 left for the monkey, or the remainder couldn't be evenly divided
into Q parts. This page calculates the pile size needed for N people to each give
one to the monkey and then take P/Q of the remaining pile.
NOTE: Q>P>0 must be true, with integer P and Q.