Python Forum
Another infinite loop
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another infinite loop
#8
Fixed it, thanks for all your help. In the end I used this.
monthlyInterestrate=annualInterestRate/12
balance_initial=balance
lowerbound=(1/12)*balance
upperbound=balance*(1+monthlyInterestrate)**(12)/12
while balance >.0001 or balance<-.0001:
    balance=balance_initial
    monthlyPayment=(upperbound+lowerbound)/2
    for i in range(12):
        balance=balance-monthlyPayment + (balance-monthlyPayment)*monthlyInterestrate
    if balance>0:
            lowerbound=monthlyPayment
    if balance<0:
            upperbound=monthlyPayment
     
print('Lowest Payment: ' + str(round(monthlyPayment, 2)))
Reply


Messages In This Thread
Another infinite loop - by wlsa - Jul-19-2018, 12:41 AM
RE: Another infinite loop - by ichabod801 - Jul-19-2018, 01:37 AM
RE: Another infinite loop - by wlsa - Jul-19-2018, 02:03 AM
RE: Another infinite loop - by buran - Jul-19-2018, 03:31 AM
RE: Another infinite loop - by ichabod801 - Jul-19-2018, 06:21 AM
RE: Another infinite loop - by buran - Jul-19-2018, 06:41 AM
RE: Another infinite loop - by ichabod801 - Jul-19-2018, 06:43 AM
RE: Another infinite loop - by wlsa - Jul-20-2018, 12:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Infinite loop Danado 4 2,440 Aug-16-2021, 05:56 PM
Last Post: deanhystad
  Help with while loop creating an infinite loop. FWendeburg 3 3,156 Jan-30-2019, 08:28 PM
Last Post: FWendeburg
  Infinite loop/ only half working anclark686 5 4,864 Sep-09-2018, 07:31 AM
Last Post: buran
  Why is this giving me an infinite loop? wlsa 4 4,014 Jul-25-2018, 10:11 PM
Last Post: cyberpatje
  How to stop an infinite loop in spyder if it's currently running? wlsa 3 24,848 Jun-30-2018, 03:27 AM
Last Post: ichabod801
  Infinite loop Truman 9 9,286 Jan-19-2018, 11:25 PM
Last Post: j.crater

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020