#How to find "i"
import random
PV = 3790.75
P = 1000.
n = 10
a = random.random()+1.
Tol = 0.001
No = 10000
def f(PV, P, n, x):
f = x**(-n) + (PV/P)*x - (PV/P) - 1.
return f
def fp(PV, P, n, x):
f = -n*x**(-n-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)-1.)
break
i = i+1
a = p
if i>No:
print ('unsuccess')