Thread: Help w/ python.
View Single Post
Old 2005-10-30, 00:27   #7
marc's Avatar
Jun 2004

100010112 Posts

It doesn't exactly relate to the programming but there's a closed expression for this.

If a is your initial investment then a * r^n is equal to the value of your investment after t years. so ar^n >= 2a when log(a) + log(r^n) >= log(a) + log(2) ie. when n >= log(r)/log(2). If you were given the interest rate of say 5% you'd convert this to r=1.05.

math.ceil(math.log(r) / math.log(2))
marc is offline   Reply With Quote