How do I calculate the return given the discount factor and a sequence of rewards?
You know all the rewards. They're 5, 7, 7, 7, and 7s forever. The problem now boils down to essentially a geometric series computation.
$$ 
G_0 = R_0 + \gamma G_1
$$
$$ 
G_0 = 5 + \gamma\sum_{k=0}^\infty 7\gamma^k 
$$
$$ 
G_0 = 5 + 7\gamma\sum_{k=0}^\infty\gamma^k 
$$
$$ 
G_0 = 5 + \frac{7\gamma}{1-\gamma} = \frac{5 + 2\gamma}{1-\gamma}
$$