The gravitational force between two particles with masses m and M, initially at rest at great separation, pulls them together. When their separation becomes d, then speed of either particle relative to the other will be :
√2G(M+m)d
By linear momentum conservation :
MV = mv .....(i)
By energy conservation
0=−GMmd+12MV2+12mv2 .......(ii)
By solving (i) and (ii)
V+v=√2G(M+m)d