Solution :
Drawing free body-diagrams for $$m\& M,$$

we get $$T = ma$$ and $$F - T = Ma$$
where $$T$$ is force due to spring
$$\eqalign{
& \Rightarrow F - ma = Ma\,{\text{or,}}\,F = Ma + ma \cr
& \therefore a = \frac{F}{{M + m}} \cr} $$
Now, force acting on the block of mass $$m$$ is
$$ma = m\left( {\frac{F}{{M + m}}} \right) = \frac{{mF}}{{m + M}}.$$