Let the focal length of the lens is f and magnification is m.
Case-I: when object is at 15 cm, image is virtual.
u=−15 cm
Using, m=vu, v=−15m
Lens formula, 1f=1v−1u
1f=1−15m+115
15f=1−1m .....(1)
Case-II: when object further moved 10 cm away from lens, image is real (magnification is negative).
u=−(15+10)=−25 cm
Using, m=vu, v=25m
Again by lens formula, 1f=1v−1u
1f=125m+125
or, 25f=1+1m .....(2)
Now, equation (1) + (2):
40f=2⇒f=20 cm