Consider the two blocks plus the spring to be the system. No external force acts on this system in horizontal direction. Hence, the linear momentum will remain constant. Suppose, the block of mass M moves with a speed V and the other block with a speed ν after losing contact with the spring. from conservation of linear momentum in horizontal direction, we have
MV−mν=0 or V=mνM
Initially, the mechanical energy of the system =12kx2
Finally, the mechanical energy of the system 12mν2+12MV2
As there is no friction, mechanical energy will remain conserved.
Therefore,
12mν2+12kx2
Solving Eqs. (i) and (ii), we get
ν=[kMm(M+m)]12x
V=[kmM(M+m)]12x