rbt wrote:
Is this mathematically correct?
def inflation():
start = int(str.strip(raw_input("How much money do you need each
month at the start of retirement: ")))
inflation = float(str.strip(raw_input("What will inflation average
over the next 30 years(.03, .04, etc): ")))
for x in xrange(30):
start = start*inflation+start
print start
inflation()
I'm not really familiar with financial calculations, but it looks
correct. There's a faster way though, since repeated multiplication is
the same as taking the power with the number of years as the exponent:
def inflation():
start = ... # same as before
inflation = ... # same as before
print start * (1+inflation)**30
--
If I have been able to see further, it was only because I stood
on the shoulders of giants. -- Isaac Newton
Roel Schroeven