Solution (source code)

= Solution

Each photon loses a factor $(1+z)^{-1}$ in energy, and <cosmological time dilation> reduces the photon arrival rate by another factor $(1+z)^{-1}$. Hence
$$
L_{\rm received}=\frac{L}{(1+z)^2},
$$
so $n=2$. The physical area of the sphere today is $4\pi a(t_0)^2x^2$, giving flux
$$
\boxed{F=\frac{L}{4\pi a(t_0)^2x^2(1+z)^2}.}
$$