Skip to content

Instantly share code, notes, and snippets.

@exiva
Forked from anonymous/gist:7175855
Created October 26, 2013 23:38
Show Gist options
  • Save exiva/7175931 to your computer and use it in GitHub Desktop.
Save exiva/7175931 to your computer and use it in GitHub Desktop.
balance = 5000
annualInterestRate = 0.04
monthlyIntr = annualInterestRate/12
lo = balance/12.00
hi = balance
guessed = False
while guessed == False:
print "Start"
# print "Lo: "
print lo
print hi
guess = (lo+hi)/2
newbal = 0
for i in range(0,12):
newbal = (newbal-(guess))*(1+monthlyIntr)
# print newbal
if newbal > 0.12:
lo = guess
# print "too low"
elif newbal < 0.12:
hi = guess
# print "too high"
# print guess
print "after"
print lo
print hi
# else:
# # print "got it."
# guessed = True
# break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment