Mass per unit length of rod, `= M//L`. Consider a small element of the rod of thickness `dx` at a distance `x` from the centre of sphere.
Mass of this element, `dm = (m)/(L) dx`
gravitational attraction between element and the sphere is,
`dF = (GM dm)/(x^(2)) = (GM)/(x^(2)).(m)/(L) dx = (GM m)/(L) (dx)/(x^(2))`
Total Gravitational attraction acting on the rod can be obtained by integrating it which the limits `x = r` to `x = r + L`. We get,
`F = (GMm)/(L) underset(r) overset(r + l) int (dx)/(x^(2)) = (GM m)/(L) [-(1)/(x)]_(r )^(r + L) = (GM m)/(r (r + L))`