Suppose CP of 1 pen = x
CP of 15 pen = 15x = SP of 20 pen
SP of 1 Pen = 15x/20
SP of 15 Pen = 15x *15/20 (as we have to bring number of pens sold and purchased to be equal, so say we are considering everything for 15 pens)
Loss on 15 pens = CP of 15 pen-SP of 15 pen = 15x – 225x/20 = 75x/20
Loss% = [Loss/CP]. 100 = [(75x/40)/15x]. 100 = 25%