If you add 4+5+7 = 16, you can consider that Frank gets 4/16 of the sweets, Mary gets 5/16 and Seth gets 7/16. This because for every 4 sweets Frank gets, Mary gets 5 and Seth gets 7.
If there are ‘x’ sweets in total, then Frank gets (4x)/16 of them, etc…
As Seth gets 18 more than Frank, we can say that [(7x)/16] – [(4x)/16] = 18
If we rearrange and solve this, we get x = 96, which is our total number of sweets.