Say we start from the beginning with $40. If the pants are discounted but we don't know the percent discount, then we need a variable, x:
40 - x% * 40 = 30
The total is 40. When we take a discount off of 40, we are taking a percent of 40 and subtracting that from 40. From the problem, this should be 30. Thus, the equation above.
Add x%*40 to both sides and subtract 30 from both sides: