Rotational inertia by integration
For a continuous body the sum becomes $I = \int r^2\,dm$, which gives $\frac{1}{3}ML^2$ for a rod about its end and $\frac{1}{12}ML^2$ about its centre, and the parallel-axis theorem $I = I_{cm} + Md^2$ links the two.
From AP Physics C: Mechanics.