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 \(\frac{b-1}{3}\) grid and has none leftover. What is the maximum number of candies in Sally's bag?
the number of condies she has is ab+2a+b or also (5ab-5a-4b+4)/3. settings these equal you get 3ab+6a+3b=5ab-5a-4b+4 => 2ab-11a-7b+4=0.
using simon's favorite factoring trick, it becomes 2a(b-11/2)-7(b-11/2)=77/2 - 4
so (2a-7)(b-11/2)=69/2
doubling both sides you get (2a - 7)(2b - 11) = 69, and the factors of 69 are 1, 3, 23, and 69, which correspond to the pairs of a and b as (4, 40), (5, 17), (15, 7), and (38, 6). the values of the candies in her bag can be 208 or 142, because some cases will not work because of the (b-1)/3.
so the answer is 208.
HOPE THIS HELPED!