import random
PV = 4329.48
P = 1000
n = 1
t = 5
m = n*t
a = random.random()
tol = 0.000001
No = 100
def f(PV,P,m,i):
f = (PV/P)*i + (1+i)**(-m)-1.
return f
def fp(PV,P,m,i):
f = -m*(i+1)**(-m-1.)+(PV/P)
return f
i = 1
while i <= No:
p = a-f(PV,P,n,a)/fp(PV,P,n,a)
if abs(p-a)<tol:
print('success')
print('i = ', round(p,2))
break
i = i+1
a = p
if i>No:
print('unsuccess')