Question: A sphere of radius $R$ has total mass $M$ and density function given by $ρ = kr$, where $r$ is the distance a point lies from the centre of the sphere. Give an expression for the constant $k$ in terms of $M$ and $R$.
My Attempt: $ρ$ is defined as density, meaning $ρ=\frac{M}{Volume}$. Volume of a sphere $= \frac{4}{3}\pi R^3$. Therefore, $ρ=\frac{M}{\frac{4}{3}\pi R^3}=\frac{3M}{4\pi R^3}$. Substituting in $ρ = kr$, I am left with $$kr=\frac{3M}{4\pi R^3}$$ and therefore need to find an expression for $r$ in terms of $k$, $M$ and/or $R$, but am unsure how to continue from here.
Please help!

Take a shell of infinitesimal thickness $dr$ at a distance $r$ from the centre. The mass of this shell would be $$dM = 4\pi r^2dr \times \rho(r) = 4 \pi r^2 kr dr$$ Then integrate both sides to find the mass as a function of $k$ $$M = \int_0^R 4 \pi r^2 \cdot kr dr = 4\pi k \frac{R^4}{4}$$ Therefore, the value of k is $$\boxed{k = \frac{M}{\pi R^4}}$$