Once two companions went on a journey. One of them had five loaves with him, and the other one had three loaves. On the way they were joined by a stranger who shared the loaves with them. On departure the stranger gave them an amount of eight dirhams. A dispute arose between the two companions about the division of the amount. The man who had five loaves wanted to keep five dirhams for himself and give three dirhams to his companion. His companion did not accept this decision and insisted that the amount should be divided equally between them, and that each one of them should get four dirhams. The men wanted Ali to decide their dispute. While entertaining the suit, Ali asked the man who had three loaves that he should accept what his friend offered him namely three dirhams. He did not accept the offer, and wanted that the matter should be adjudicated so that due justice was done. Ali asked whether at the time of the sharing of loaves all the three persons concerned had equal share. He was told that it was so. Ali thereupon gave the judgment that the man with three loaves was entitled to one dirham while the other man who had five loaves was entitled to seven dirhams. This bewildered the man with three loaves who would not accept even three dirhams. He wanted Ali to enlighten him as to the basis of his judgment. Ali explained the position thus: "You had three loaves and your companion had five loaves. There were thus 8 loaves in all. As all the loaves were shared equally between three persons, divide each loaf into three pieces. That would make 24 pieces. Your companion owned five loaves or fifteen pieces while you owned three loaves or nine pieces. As these 24 pieces were shared equally, this means that each one of you ate eight pieces. You had nine pieces, and out of these you ate eight pieces yourself. Thus the stranger ate only one piece from your loaves. Your companion had fifteen pieces. Out of these he ate eight pieces himself leaving seven pieces which were eaten by the stranger. Thus the stranger ate one piece from you and seven pieces from your companion. It is therefore plain arithmetic that for one piece you are entitled to one dirham and your companion is entitled to seven dirhams for seven pieces."