Answer:
- def doubling_time(bal, apr):
- current_amount = bal
- year = 0
- while(current_amount < bal * 2):
- current_amount = current_amount + (current_amount * apr/ 100)
- year += 1
-
- return year
-
- print(doubling_time(200, 10))
Step-by-step explanation:
The solution is written in Python 3.
Firstly create a function that takes two input bal and apr (Line 1). Next set the bal as current amount (Line 2) and create year variable as a counter of year (Line 3).
Create a while loop and set the loop condition to enable the while loop persist so long as the current amount still less than the double of initial balance (Line 4). In the while loop, apply formula to compute the current amount after adding the annual interest and then increment year counter by one (Line 5 -6). The year counter will keep increment until the current amount is double the initial balance and terminate the while loop. Return the year counter as function output (Line 8).
We test the function by passing 200 and 10 as initial balance and annual interest rate, respectively. We shall get return value 8.