Solution (source code)

= Solution

Apply the <product rule> and the preceding <gradient> formula to the <vector field> $F_i=f(r)x_i$. Summing over the repeated index gives
$$
\partial_iF_i=f'(r)\frac{x_i x_i}{r}+f(r)\delta_{ii}
=rf'(r)+nf(r).
$$
Here $\delta_{ii}=n$ for the <Kronecker delta>. Thus the <divergence and curl of a radial vector field> give, in any dimension,
$$
\boxed{\nabla\cdot[f(r)\mathbf x]=rf'(r)+nf(r).}
$$