Solution (source code)

= Solution

In <spherical coordinates>, integrating over the angular variables gives the <volume element> $4\pi r^2\,dr$ for a spherical shell. The <mass density> therefore gives the total <mass>
$$
M=4\pi\int_0^a(1+r)r^2\,dr
=4\pi\left[\frac{r^3}{3}+\frac{r^4}{4}\right]_0^a.
$$
Thus
$$
\boxed{M=\frac{4\pi a^3}{3}+\pi a^4}.
$$