7. The number of apples produced by a group of farmers is less than 1000. It is known that they shared the apples in the following way. In turn, each farmer took from the collection of apples either exactly one-half or exactly one-third of the apples remaining in the collection. No apples were cut into pieces. After each farmer had taken his share, the rest was given to charity. Find the greatest number of farmers that could take part in the apple sharing.
7. A group of farmers harvested a batch of apples, fewer than 1000. They shared the apples in the following way: each person took a turn to take either exactly half or exactly one-third of the remaining apples, and no apples were cut. After all the farmers had taken their share, the rest was donated to charity. What is the maximum number of farmers who could participate in the apple sharing?
7. 12
7. If there are 729 apples, it is possible that 12 farmers took part in the sharing if the odd-numbered farmers took one-third of the remaining apples and the even-numbered farmers took one-half of the remaining apples. In this case one apple is left after the last farmer took his apple and the number of apples remaining is an integer throughout.
Now suppose \( p \) farmers took one-half of the apples and \( q \) farmers took one-third of the apples. We will show that \( p+q \leq 12 \), so that 12 is indeed the greatest possible number of farmers. We have
\[
1000 \geq 2^{p}\left(\frac{3}{2}\right)^{q}=2^{p-q} 3^{q}=4^{\frac{p-q}{2}} 3^{q} \geq 3^{\frac{p-q}{2}} 3^{q}=3^{\frac{p+q}{2}},
\]
from which \( p+q \leq 12 \) follows.