Solution (source code)

= Solution

Let $p=K\rho^{1+1/m}$. <Hydrostatic equilibrium> in the uniform gravitational field gives
$$
\frac{dp}{dz}=-\rho g.
$$
Substitution and integration with $\rho=0$ at $z=0$ gives
$$
\rho=\rho_0\left(\frac{-z}{H}\right)^m,
\qquad z\leq0,
$$
where $H$ fixes the normalization. Integrating the hydrostatic equation from $z$ to the free surface gives the pressure directly:
$$
p(z)=g\int_z^0\rho(z')\,dz'
=\boxed{\frac{\rho_0gH}{m+1}
\left(\frac{-z}{H}\right)^{m+1}}.
$$
This indeed has $p\propto\rho^{1+1/m}$ and $p(0)=0$, as required for a <polytropic atmosphere>.