#declared by checker balance = 999999 annualInterestRate = 0.18 #start program here monthly_interest_rate = annualInterestRate / 12.0 monthly_payment_lower_bound = balance / 12 monthly_payment_upper_bound = (balance * ((1 + monthly_interest_rate) ** 12)) / 12.0 lowest_monthly_payment = 0 running_balance = balance while (round(running_balance, 2) != 0.00): running_balance = balance lowest_monthly_payment = (monthly_payment_upper_bound + monthly_payment_lower_bound) / 2 for i in range(1, 13): monthly_unpaid_balance = running_balance - lowest_monthly_payment running_balance = monthly_unpaid_balance + (monthly_interest_rate * monthly_unpaid_balance) if (running_balance > 0.00): monthly_payment_lower_bound = lowest_monthly_payment else: monthly_payment_upper_bound = lowest_monthly_payment print ("Lowest Payment: " + str(round(lowest_monthly_payment, 2)))
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question