Why do large values cause an infinite loop in this program?
<p>This is a program I made to calculate credit card balance. It works for most inputs, but when <code>balance</code> gets too large, the program runs an infinite loop. What can be done to improve the code so that it calculates even the larger values?</p>

<pre><code>monthlyPayment = 0

monthlyInterestRate = annualInterestRate /12
newbalance = balance
month = 0

while newbalance &gt; 0:
    monthlyPayment += .1
    newbalance = balance

    for month in range(1,13):
        newbalance -= monthlyPayment
        newbalance += monthlyInterestRate * newbalance
        month += 1
print("Lowest Payment:" + str(round(monthlyPayment,2)))
</code></pre>

<p>You must make the testing condition of <code>while</code> become <code>False</code>. Since it is <code>newbalance &gt; 0</code>, it should eventually emerge from the <code>for</code> loop with a positive value.</p>

python python-3.x infinite-loop