Two steps. The first sizes the target using the 4% rule, which inverted is the "rule of 300": if you can withdraw 4% a year, you need 300 times your monthly spending.
target wealth = desired monthly income × 300
The second works out the monthly contribution that reaches that figure in the years you have left, at an 8% annual return, using the standard payment formula:
contribution = target × r / ((1 + r)^n − 1) r = 0.08 / 12 n = years × 12
Note what it does not do: it does not count what you have already saved. The figure it returns is the contribution needed starting from zero, so if you already hold assets your real contribution is lower.
