In case it helps you I attached a diagram showing the path of the beam of light through the gradient of the atmosphere.
Remember with glass the refractive index changes suddenly from air to glass. In the case of the atmosphere it changes **gradually** the higher up you go (due to the decreasing pressure). As a result of this the light continuously curves.
Now that you see the visual respresentation of how it works, again, attempt the equation, and if you dont know how, ASK, I will teach you whichever part you are confused on but you need to attempt the math so we have something to correct or learn from.