oh, wow, tough one, took me some time to get to the answer:
ok, so suppose we have n - number of doughnuts and x - price paid for each one. nx = 15$.
now, because the doughnuts were not in good shape, he received n+3 doughnuts.
we are told that with the new quantity, the price for 12 would be -2$. this is where the trick part is...
1 doughnut cost 15/n. now, 15/n * 12 = 180/n. this is the price for 12 doughnuts, and from this, we deduct 2.
180/n -2. let's rearrange everything: (180-2n)/n. now looks better.
ok, so if this is the new price for 12 doughnuts, then the price for 1 doughnut would be (180-2n)/n * 1/12 or (90-n)/6n.
now we are getting closer:
he received n+3 at the price (90-n)/6n. and the total is 15.
we can make a new equation:
(n+3)(90-n)/6n = 15 | multiply both sides by 6n
(n+3)(90-n) = 90n
90n-n^2+270-3n = 90n | subtract 90n from both sides, then multiply by -1.
n^2+3n-270=0.
factor the equation: (n-15)(n+18)=0.
we have n=15 and n=-18. Since we are talking about real things, n can't be -18. thus, n must be 15.
now, n is the initial number of doughnuts he bought, but then he received 3 more. so the total number should be 15+3 = 18.