1. recursion.py
intRate = 0.05 def compound(amt, termsRemaining): if(termsRemaining == 0): return amt else: termsRemaining = termsRemaining - 1 newamt = amt + (amt*intRate) return compound(newamt, termsRemaining) print(compound(100,2))
def closegap(x,y):
if x == y:
print("values are now level")
return x
else:
return closegap(x+1, y)
print(str(closegap(11,22)))
which prints values are now level
and 22
which is the final value of x (level with y).