Sharing cake: Solution

Share this page

Which piece do you want?

Two people on a long walk sit down for a well-deserved break. Person A has brought along 3 cakes to eat and person B has brought along 5.

As they are just about to tuck in, person C arrives and asks to share their meal. A and B agree. They cut each cake into three equal pieces and each person eats one piece of each cake.

After the meal person C pays 8 coins for the cake. Person A gives B 5 of these coins and keeps 3. But person B complains. She demands to be given 7 of the coins with only 1 remaining for A.

Who is right and why?

Can you generalise the solution for an initial $k$ people having $n_1, n_2, ...,n_ k$ cakes respectively, who are then joined by another $m$ people who pay $n_1+n_2+n_3+...+n_ k$ coins each?

We'd like to thank Syed Abbas, Associate Professor and Chairperson SBS, IIT Mandi, India, for sending in this puzzle. Reportedly, a version of it was put to Ali ibn Abi Talib in the seventh century AD. Another version also appears in Fibonacci's famous Liber Abaci.


It turns out that Person B is right. After sharing each cake into three pieces there are a total of 8x3=24 pieces. They are divided equally between the three people, which mean that every person eats 8 pieces. To start with person A has 3x3=9 pieces and person B has 3x5=15 pieces. Out of his 9 pieces person A eats 8, which means that he has given away 1. Out of her 15 pieces person B eats 8, which means that she has given away 7 pieces. Therefore, person B should receive 7 coins and person A only 1.

Now for the general version of the problem. There are a total of

  \[ n_1+n_2+n_3+...+n_ k \]    

cakes which are each divided into $k+m$ pieces, which means there are

  \[ (n_1+n_2+n_3+...+n_ k)(k+m) \]    

pieces of cake in total. Each person eats

  \[ (n_1+n_2+n_3+...+n_ k) \]    


The $ith$ person, call them $k_ i$ brought along $n_ i$ cakes, so they initially have

  \[ (m+k)n_ i \]    

pieces. Since they eat

  \[ n_1+n_2+n_3+...+n_ k \]    

pieces themselves they should be paid

  \[ (m+k)n_ i-(n_1+n_2+n_3+...+n_ k) \]    


To double check, the total number coins received is

  $\displaystyle  $ $\displaystyle (m+k)n_1-(n_1+n_2+n_3+...+n_ k) $    
  $\displaystyle + $ $\displaystyle (m+k)n_2-(n_1+n_2+n_3+...+n_ k)+... $    
  $\displaystyle + $ $\displaystyle (m+k)n_ k-(n_1+n_2+n_3+...+n_ k) $    
  $\displaystyle = $ $\displaystyle (m+k)(n_1+n_2+n_3+...+n_ k)-k(n_1+n_2+n_3+...+n_ k) $    
  $\displaystyle = $ $\displaystyle m(n_1+n_2+n_3+...+n_ k),  $    

which equals the total number of coins that are being paid.


Correct me If I am wrong, the question specifically states that "each person eats one piece of each cake." This means that if A brings 3 cakes and B brings 5 cakes then person C eats one piece of each cake, so he must eat 3 pieces from A and 5 pieces from B. Hence if each piece costs 1 coin, 3 coins should go to A while 5 to B.

For summarising the solution to this answer I got the general equation of (3n*(Σp-k))/Σp. the letter 'n' is the number of cakes present, 'Σp' is the total number of people eating cakes. The 'k' is the number of people who provide the cakes. The expression 'Σp-k' is the number of extra people. The equation provides a result for the sum of all coins that need to be paid back this will be 'Σc', to calculate the number of coins that need to be paid back per person the Σc needs to be divided by the number extra people this gives the result (Σc)/(Σp-k). Thus we can state that the number of coins that need to be paid back per person is given by equation (3n*(Σp-k))/((Σp*(Σp-k)) = Σc/Σp-k. This simplifies the left side equation to 3n/Σp.

Thus the formulas I obtained are:
- (3n*(Σp-k))/Σp = Σc : sum of coins needed to be paid back
- (Σc)/(Σp-k) or 3n/Σp : number of coins that need to be given back per person

I think that the problem with the question lies in the wording, the answer provided is correct is the people ate the 8 cakes between each other. I also would like to say that the answer provided would only be one of many possible answers, this is because it assumes that person A eats all her cakes and then gives the others away. However if they were the to randomly eat 8 slices each the number of combinations possible would be 24!/8! (each slice is on its own) where the combination in the answer would be just one of many.

I am not sure if my maths is 100% correct, please do correct me if I have made any mistakes!


A gave 6 pieces from his cake and took 5 pieces from B own + 3 from his own = so he got 8 pieces from all the cake so he pay for three cake 9 pieces

B gave 10 pieces from here cake and took 3 pieces from A own + 5 from her cake = so she took same 8 pieces from all cake but she pay for five cake 15 pieces


B PAY FOR 15 PIECS ABD GIT 8 PIECES -----> 15-8= 7

SO A will take only 1 for his one piece
And B will take 7 for her pieces

  • Want facts and want them fast? Our Maths in a minute series explores key mathematical concepts in just a few words.