Solution (source code)

= Solution

For a radial <null geodesic>, the <FLRW metric> gives
$$
\int_{t_e}^{t_0}\frac{c\,dt}{a(t)}=\int_{r_e}^{r_0}\frac{|dr|}{\sqrt{1-kr^2}}.
$$
Two successive wave crests traverse the same comoving path between <comoving observers>. Subtracting their path integrals, to first order in their short emission and reception periods, gives $\delta t_0/a(t_0)=\delta t_e/a(t_e)$. Since <cosmic time> is each observer's proper time and the <frequency> is the reciprocal period,
$$
\boxed{1+z=\frac{\nu_e}{\nu_0}=\frac{a(t_0)}{a(t_e)}.}
$$
This neglects <peculiar velocities> and local <gravitational redshift> contributions.

For B's light passing through A on its way to Earth, with the comparison event at A being that passage, <cosmological redshift> factors multiply:
$$
1+z_B=(1+z_{BA})(1+z_A),\qquad
\boxed{z_{BA}=\frac{4}{2}-1=1.}
$$
This is the intended numerical answer with that reception-event specification. The <reception-event dependence of intergalactic redshift> is essential: Earth's two redshifts by themselves neither specify the A–B separation nor identify the emission event at B whose light A receives at a chosen time. For arbitrary directions or a different reception time at A, the general answer is $a(t_{A,\rm rec})/a(t_{B,\rm em})-1$, with the emission time fixed by the A–B <null geodesic>; it cannot be deduced from the two supplied numbers alone.