I am having a very slow Friday and cannot think of how to describe my problem in mathematical terms...
I have 10 children who each must get an apple, a banana and an orange. Apples come in bags of 3, bananas in bunches of 7 and oranges in bags of 4.
To give each child one of each type of fruit, I need to buy 4 bags of apples, 2 bunches of bananas and 3 bags of oranges.
Simple.
I now see that I could accommodate an extra 2 children with the fruit that I have bought.
I need to come up with an expression that will show me the max number of children I can feed given that I HAVE TO feed 'x' number of children?
The amount of extra kids you can feed is the minimum amount of excess you have for each of the fruits you're buying. For example, if you have $1$ extra apple, $2$ extra bananas and $3$ extra oranges, then the amount of kids you can feed is:
$$\min(1,2,3)=1$$
You can find these $\min$ values using the following method. Let's pretend we have $10$ kids. Then we find that:
$$\frac{10\text{ kids}}{3\text{ apples}}=3\text{ Remainder }1$$ $$\frac{10\text{ kids}}{7\text{ bananas}}=1\text{ Remainder }3$$ $$\frac{10\text{ kids}}{4\text{ oranges}}=2\text{ Remainder }2$$
This calculation tells us how many bags of each fruit we need to buy in order to feed our $x=10$ kids. Obviously we cannot buy partial bags, so we can take the remainder terms and subtract it from the amount of each type of fruit, i.e.:
$$\text{For apples: }3-1=2$$ $$\text{For bananas: }7-3=4$$ $$\text{For oranges: }4-2=2$$
These values tell us how many fruit we have extra from each bag. As I stated at the beginning, you can take the $\min$ of these to find how many kids $y$ you can feed extra, in this case:
$$\min(2,4,2)=2\text{ Extra Kids}$$
Generally, for some number $x$, you can take the modulo of $x$ (what will provide you the remainder term in the above calculation) to find the remainder term for each fruit, then subtract that number from the amount of fruit sold in each bag, and then take the $\min$ of those numbers. So:
$$y=\min(a,b,o),\text{ where}$$ $$a=3-(x\mod(3)),b=7-(x\mod(7)),o=4-(x\mod(4))$$