Let a = acceleration with which the mass "M" moves downwards and mass "m" moves upwards.
T = tension in the string
Net downward force acting on mass M is
F = Mg - T
But F = Ma
Hence, Ma = Mg - T ...(i)
Net upward force acting on mass 'm' is
ma = T - mg ....(ii)
Adding (i) and (ii), we get
(M + m)a = g(M - m)
⇒ a = ({M - m}/{M + m}) x g
Putting this value in equation (ii), we have
m({M - m}/{M + m})g = T - mg
⇒ T = mg[{M - m}/{M + m} + 1]
= [{2M}/{M + m}] x g