Alice, Bob and Carol sit around a round table. Initially Alice has $n$ cookies, while Bob and Carol have none. Alice divides her cookies evenly between Bob and Carol; if there is a leftover cookie (as $n$ is odd) then Alice eats it. Then Bob does the same with his cookies, then Carol does the same with hers. And so on, and so on, and so on. The process continues forever: in a round-robin fashion, everybody divides his/her cookies evenly between the other two persons and eats leftovers if there are any.

Question: For which starting values of $n\ge1$ does the process continue forever WITHOUT a single cookie being eaten?


4 Answers 4


The answer is:

there is no such number.

Let's define the amount of cookies at the beginning as $1$, and look at the fractions everyone has after each round:










As can be seen above all numerators are odd, and all denominators are a power of $2$. And this will stay that way, because every new numerator is $2*previous \space numerator$ which gives an even number and after adding another odd numerator it becomes odd again. That way the fraction can never be reduced, and we never get a loop which would be required for this to work.

Extension to 4 friends (requested by ghosts_in_the_code):

The proof works similar to the above case, we start with $1$ again:









None of the numerators in the example is divisible by $3$. New numerators are created by $3*previous \space numerator$ which is obviously divisible by $3$, and adding of another numerator (not divisible by $3$) which makes the new numerator not divisible by $3$ again.

This can be extended to any number of friends.

  • $\begingroup$ Just an add-on: What if there were 4 friends and cookies were divided among the other 3? Can the same answer be generalised for such a puzzle also? $\endgroup$ Commented Sep 17, 2015 at 15:30
  • $\begingroup$ @ghosts_in_the_code I'm afraid I just killed the "Generalized cookie sharing" question. ;) $\endgroup$
    – Sleafar
    Commented Sep 17, 2015 at 19:27
  • $\begingroup$ I didn't get you. $\endgroup$ Commented Sep 18, 2015 at 7:09
  • $\begingroup$ @ghosts_in_the_code I was referring to the questions that generalize a previous question replacing specific numbers with $n$. I think the extension of the answer covers it all. $\endgroup$
    – Sleafar
    Commented Sep 18, 2015 at 7:13

The answer, as already others have said, is

there are no $n$ for which this is true.

Here is another proof why. Assume a cookie is never eaten. We can think of the situation as a series of states, $s_0,s_1,s_2,\dots$, where each $s_i$ is a triple $(a,b,c)$ of how many cookies each person has.

Eventually, a state must repeat. Suppose that $s_i$ is the first repeated state, and the first time it repeats is at step number $j$ (so $j>i$ and $s_j=s_i$). There are two possibilities:

  • CASE 1: $i\ge1$. This means that $s_{i-1}$ and $s_{j-1}$ are distinct states which both lead to state $s_i$. This is impossible: when no cookies are eaten, each state has a unique state which leads to it. For example, the unique state leading to $(a,b,0)$ is $(a-b,0,2b)$.

  • CASE 2: $i=0$. This means that the state $s_{j-1}$ leads to the state $s_j=s_0=(n,0,0)$. Again, this is impossible: as long as no cookies are eaten, then after each move, there will be two people who have cookies, so no state can lead to $(n,0,0)$.

Either way, assuming no cookies are eaten leads to a contradiction.


There are no such solutions!

To see this explicitly we can calculate how many cookies the 3 people ( A, B and C ) have at a given stage. To do this I altered the problem by assuming that after person A (Alice) shares their cookies for the first time, everyone gives their cookies to the person alphabetically before them: so C gives to B, B gives to A and A gives to C. In practice this gives the following for the first 2 stages:

At stage 1: A has n, B has 0 and C has 0

At stage 2: A has n/2, B has n/2 and C has 0

We can repeat this procedure of A halving the cookies and then the cookies being shifted along (so now only Alice halves her cookies). This generates the same fractions to appear at each stage as the original problem yet different people will have different fractions. (The shift essentially changes A into person B on stages that are 2 mod 3, C on 0 mod 3 stages and A on 1 mod 3 stages)

(note C will always have 0 cookies)

From this we can calculate how many cookies people have at a given stage in the new altered problem (and this will be a permutation of the solution to the original problem as discussed above).

Let A(i),B(i) denote the cookies A and B have a stage i. We have $A(1) = n$ and $B(1) = 0 $

We now consider how A(i) changes in the altered problem, we deduce:

$A(i+1) = B(i) + \frac {A(i)} {2} $

and $B(i+1) = \frac{A(i)} {2} $

Therefore $B(i) = \frac{A(i-1)} {2}$ from that second equation

Substituting this back in to the first gives (after arranging): $2A(i+2) - A(i+1) - A(i) = 0$

This is a standard difference equation which we can solve with the initial conditions I wrote above. I'll leave out the algebra. This gives:

$ A(i) = \frac {2n}{3} \frac{2^i - (-1)^i} {2^i}$ and since no cookies are eaten B(i) = n - A(i)

And from this we know how many cookies A has in the altered problem which implies someone in the original problem has A(i) cookie at a given stage. We now note that A(i) must always be an integer for the cookies to be halved correctly without one being eaten.

However it is clear that $(2^i - (-1)^i)$ is always an odd number so for A(i) to be an integer for all i, 2^i must divide n for all positive intgers i. This is not possible unless we are in the trival case in which n=0.

(note it is possible to calculate exactly how many cookies each person has at a stage by combining the solution to the difference equation with my comment :'(The shift essentially changes A into person B on stages that are 2 mod 3, C on 0 mod 3 stages and A on 1 mod 3 stages)')


The number of cookies a person receives is halved at each round, until eventually it becomes 1. At this time the cookie can't be shared anymore and must be eaten. So, for the process to continue forever, $n$ must be an infinitely large power of two.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.