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))
