![](/content/sites/plus.maths.org/files/styles/small_square/public/cake_frontpage_0.jpg?itok=3Wl1jf-T)
![Cake](/content/sites/plus.maths.org/files/news/2016/cake/cake.jpg)
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.
Solution
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)$$ pieces. 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)$$ coins. To double check, the total number coins received is \begin{eqnarray*}&(m+k)n_1-(n_1+n_2+n_3+...+n_k)\\ +&(m+k)n_2-(n_1+n_2+n_3+...+n_k)+...\\ +&(m+k)n_k-(n_1+n_2+n_3+...+n_k)\\ =&(m+k)(n_1+n_2+n_3+...+n_k)-k(n_1+n_2+n_3+...+n_k)\\ =&m(n_1+n_2+n_3+...+n_k), \end{eqnarray*} which equals the total number of coins that are being paid.