The saving that closes the gap
Existing savings grow at the nominal return until retirement and cover part of the target:
Shortfall = capital needed - existing savings x (1 + r)^n
The level yearly saving that grows to the shortfall is the payment on a future value annuity at the nominal rate. Deposits at the end of each year use the ordinary annuity formula, PMT = shortfall x r / [(1 + r)^n - 1]; deposits at the start of each year are that payment / (1 + r). Saving that rises each year with pay would start lower.