The problem asks us to find the gain percentage when a shopkeeper's gain is equivalent to the selling price (SP) of 40 pens, achieved after selling 200 pens.
The shopkeeper sold 200 pens. The profit (Gain) made is equal to the selling price of 40 pens.
Total SP for 200 pens = $200 \times S$.
Total Gain = SP of 40 pens = $40 \times S$.
We know that Gain = Total SP - Total CP.
Therefore, the Total CP for the 200 pens must be the SP of the remaining pens:
Total CP for 200 pens = Total SP for 200 pens - Gain
Total CP for 200 pens = $(200 \times S) - (40 \times S) = 160 \times S$.
This means the cost price of 200 pens is equal to the selling price of 160 pens.
The formula for Gain Percentage is:
Gain Percentage = $\frac{Gain}{Total CP} \times 100\%$
Substitute the values we found:
Gain Percentage = $\frac{40 \times S}{160 \times S} \times 100\%$
Cancel out $S$:
Gain Percentage = $\frac{40}{160} \times 100\%$
Simplify the fraction:
Gain Percentage = $\frac{1}{4} \times 100\%$
Gain Percentage = $25\%$
The gain percentage is $25\%$.