Sally has a bagful of candy. She arranges it into an A by B grid, but she has 2A+B candies leftover . Her big sister Rita comes along and says, "I can do better than that!" Rita neatly arranges the candies into a 5A-4 by B-1/3 grid and has none leftover. What is the maximum number of candies in Sally's bag?
(5A - 4) (B - 1) / 3 - AB = 2A + B
(5A - 4) (B - 1) - 3AB = 6A + 3B
5AB - 4B - 5A+ 4 - 3AB = 6A + 3B
2AB - 7B - 11A + 4 = 0
B ( 2A - 7) = 11A - 4 or
B = ( 11A - 4)
________
(2A - 7)
We have two possibilities
A B
4 40
38 6
The max candies is either
(5(4) - 4) ( 40-1)/3 = 16 * 13 = 208 or
(5(38) - 4) (6 - 1)/3 = 310
So.....310 candies