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 appears in Fibonacci's famous Liber Abaci.
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 cakes.
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 5 of these coins to person B and keeps 3 for himself. 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 people having cakes respectively, who are then joined by another people who pay coins each?