In order to calculate the distance from the second planet to Gliese 876, we can use the third law of Kepler:
Where D is the distance and T is the period of translation.
Since k is a constant, we can write the following equation:
Using D1 = 3.17*10^7 km, T1 = 65 days and T2 = 123 days, let's calculate D2:
Therefore the wanted distance is 4.85 * 10^7 km.