Copyright © University of Cambridge. All rights reserved.
'Cakes and Buns' printed from https://nrich.maths.org/
Answer: 9 cakes and 7 buns
Spotting patterns in the numbers
One cake + one bun = 23p + 39p = 62p
512 $\div$ 62 = 8 remainder 16, so buying 8 cakes and 8 buns costs 16p less
16 = 39 - 23 is the difference between them
So buy one more bun and one less cake
7 cakes and 9 buns
Using algebra
$23a$ $+$ $39b$ $=$ $512$
Those numbers are not very easy to work with so try writing it differently...
$23(a+b)$ $+\underbrace{16b}_{\text{multiple
of 16}}=\underbrace{512}_{\text{multiple
of 16}}$
So $(a+b)$ must be a multiple of $16$ as well.
Try $a+b=16$
$23\times16$ $+$ $16b$ $=$ $512$
$ 368$ $ +$ $ 16b$ $ =$ $ 512$
$16b = 512 - 386 = 144$
$144=9\times16$ so $b=9$ and so $a=7$