florence bought two bags of flour, A and B. the two bags contained different amounts of flour. the total mass was 108 kg. Gary poured 1/4 of the flour from bag A to bag B. After that, he poured 2/5 flour from bag B to bag A. he found that the both bags had the same mass now. how much flour was there in bag B in the beginning

a+b=108

3a/4 + (2/5)(b+a/4) = (3/5)(b+a/4)

now just solve for b.

To solve this problem, we can set up a system of equations to represent the given information.

Let's assume that bag A initially had x kg of flour, and bag B initially had y kg of flour.

We know that the total mass of the two bags was 108 kg, so we can write the equation:
x + y = 108 ---(Equation 1)

According to the given information, Gary poured 1/4 of the flour from bag A to bag B. After pouring, bag B would have (1/4)x kg more flour, and bag A would have (1/4)x kg less flour. So the new amount of flour in bag B is y + (1/4)x, and the new amount of flour in bag A is x - (1/4)x.

He also poured 2/5 of the flour from bag B to bag A. After pouring, bag A would have (2/5)(1/4)x kg more flour, and bag B would have (2/5)(1/4)x kg less flour. So the new amount of flour in bag A is x - (1/4)x + (2/5)(1/4)x, and the new amount of flour in bag B is y + (1/4)x - (2/5)(1/4)x.

According to the problem, the new masses of both bags are equal, so we can write the equation:
x - (1/4)x + (2/5)(1/4)x = y + (1/4)x - (2/5)(1/4)x ---(Equation 2)

To solve this system of equations, we can substitute Equation 1 into Equation 2 and simplify:

(x + y) - (1/4)x + (2/20)x = y + (1/4)x - (2/20)x
108 - (1/4)x + (1/10)x = y + (1/4)x - (1/10)x

Multiplying through by the least common denominator of 20 to eliminate the fractions, we get:
2160 - 5x + 2x = 20y + 5x - 2x
2160 - 3x = 20y + 3x

Combining like terms, we have:
6x = 20y + 2160

Now, we need to find a combination of x and y that satisfies this equation. We can start by testing some values.

Let's try x = 36 and y = 72:
6(36) = 20(72) + 2160
216 = 1440 + 2160
216 = 3600 which is false

So, x = 36 and y = 72 is not the right combination.

Let's try x = 54 and y = 54:
6(54) = 20(54) + 2160
324 = 1080 + 2160
324 = 324 which is true

So, x = 54 and y = 54 is the correct combination.

Therefore, bag B initially had 54 kg of flour.