Divide the margin by one minus the margin. A 30% margin becomes 0.30 divided by 0.70, which is a 42.9% markup. You must add 42.9% to cost to keep a 30% margin.