I am making an application to divide bills. I have the following problem:
Jhon and Paul were to a pub , and they consumed 20 beers. James get in the bar and they consumed ten more beers.
How much Paul have to pay ?
I tried this approach:
Jhon and Paul drank all beers so they have to pay all of them = 1
James just drink 1/3 of the beers.
So james have to pay 30/(1 + 1 + 0,33) = 30/2,33 = 12,87
I know the correct result is 13,33
What i'm doing wrong?
I know i can calculate the price like 20/2 + 10/3. But i'm doing an algorithm and this is hard to implement that.
That's why i wanna know what i'm doing wrong.
The correct formula is:
James drank 1/3 of the beers, but have other 2 people drank with him so, it's not 10/30 its (10 - 2,33) / 30 = 0,25
Paul have to pay 30 / (1 + 1 + 0,25)