A 40-litre can is full of milk. 4 litres are taken out and replaced with water, and this is done three times in total. How much milk is left?
29.16 litres. Each operation keeps (40 - 4)/40 = 0.9 of the milk, so after three rounds milk = 40 x 0.9^3 = 40 x 0.729 = 29.16 litres.
Explain it simply
The first time you remove 4 litres, it is pure milk. The second time, the can already holds some water, so the 4 litres you remove are only partly milk. Each round removes the same fraction (one tenth) of whatever milk is there, so milk shrinks by a fixed multiplier each time, just like depreciation.
Example
Question: 40 L of milk; remove 4 L and replace with water, 3 times. Milk left?
- Fraction kept each time = (40 - 4) / 40 = 0.9.
- Milk after round 1 = 36 L.
- After round 2 = 36 x 0.9 = 32.4 L.
- After round 3 = 32.4 x 0.9 = 29.16 L.
- Water = 40 - 29.16 = 10.84 L.
Formula: final quantity = initial x (1 - removed/total)^n = 40 x (0.9)^3.
console.log((40 * Math.pow(0.9, 3)).toFixed(2)); // Output: 29.16The question may ask for the ratio: milk : water = 29.16 : 10.84 = 729 : 271.
What to say in the interview
"Each replacement removes a tenth of the milk present, so milk is multiplied by 0.9 each time. After three rounds that's 40 times 0.729, which is 29.16 litres."
Common mistakes
- Subtracting 12 litres of milk (3 x 4), as if every removal were pure milk.
- Using n = 4 by counting the original filling as a round.