Write an algorithm to settle the following question: A bank account starts out with 10,000. Interest is compounded monthly at 0.5 percent per month. Every month, $500 is withdrawn to meet college expenses. After how many years is the account depleted? – Note you don’t have to supply the number of years it takes the account to deplete just the “algorithm” that would be used to answer that question.
initial_amount = 10000 interest_per_month = 0.5 withdrawn_per_month = 500 final_amount = 0 new_amount1 = ((initial_amount * interest_per_month) + interest_per_month) - withdrawn_per_month new_amount2 = ((new_amount1 * interest_per_month) + interest_per_month) - withdrawn_per_month new_amount3= ((new_amount2 * interest_per_month) + interest_per_month) - withdrawn_per_month
This is how far I've gotten. How would I loop this until whatever "new_amount" is equal to 0. And by the way I'm using Python.
Join our real-time social learning platform and learn together with your friends!