Solution (source code)

= Solution

A <free-fall timescale> estimate follows from $R/t^2\sim GM/R^2$:
$$
\boxed{t_{\rm dyn}\sim\sqrt{\frac{R_\odot^3}{GM_\odot}}\simeq1.6\times10^3\,\mathrm s.}
$$
Falling to a central <point mass> gives the more precise factor $\pi/(2\sqrt2)$, or $1.77\times10^3\,\mathrm s$; a distributed star changes an order-one coefficient. For any spherical <mass distribution> with radius $R$,
$$
|\Omega|=\int_0^M\frac{Gm}{r(m)}\,dm\ge\frac GR\int_0^M m\,dm=\frac{GM^2}{2R}.
$$
The inequality is strict for an extended star; equality is approached by a thin shell at $R$. For an <monatomic gas> the <virial theorem> is $2U+\Omega=0$, so half the <gravitational potential energy> released by contraction heats the star and half can be radiated. The <Kelvin-Helmholtz cooling time> is therefore of order
$$
\boxed{t_{\rm KH}\sim\frac{GM_\odot^2}{2R_\odot L_\odot}\simeq1.6\times10^7\,\mathrm{yr}.}
$$
A uniform-<density> model gives $3GM^2/(10RL)\simeq9.4\times10^6\,\mathrm{yr}$. The given bound fixes a scale, rather than an exact contraction history; both estimates are far shorter than the Sun's <main-sequence lifetime>.