from math import e def f(x): return e ** x - 2 def df(x): return e ** x def Newton(a, f, df): return a - f(a)/df(a) def main(): i = 0 a = [5] while True: a.append(Newton(a[i], f, df)) if abs(a[i] - a[i-1]) < 0.001: print(f'Iterasjoner: {i-1}, a: {a[i-1]}') break i += 1 main()