Consider the sequence `S(n, z) = (1 - z)(z + z**2 + z**3 + ... + z**n)` where `z` is a complex number
 and `n` a positive integer (n > 0).

When `n` goes to infinity and `z` has a correct value (ie `z` is in its domain of convergence `D`), `S(n, z)` goes to a finite limit
 `lim` depending on `z`.

Experiment with `S(n, z)` to guess the domain of convergence `D`of `S` and `lim` value when `z` is in `D`.

 Then determine the smallest integer `n` such that `abs(S(n, z) - lim) < eps`
 where `eps` is a given small real number and `abs(Z)` is the modulus or norm of the complex number Z.

 Call `f` the function `f(z, eps)` which returns `n`.
 If `z` is such that `S(n, z)` has no finite limit (when `z` is outside of `D`) `f` will return -1.

# Examples:
I is a complex number such as I * I = -1 (sometimes written `i` or `j`).

 `f(0.3 + 0.5 * I, 1e-4) returns 17`
 
 `f(30 + 5 * I, 1e-4) returns -1`

# Remark:
For languages that don't have complex numbers or "easy" complex numbers, a complex number `z` is represented by two real numbers `x` (real part) and `y` (imaginary part).

`f(0.3, 0.5, 1e-4) returns 17`
 
 `f(30, 5, 1e-4) returns -1`
# Note:
You pass the tests if `abs(actual - exoected) <= 1`

Difficulty: introductory

Starter code:

def f(z, eps):
	

Solutions:
import math

def f(z, eps):
    if (abs(z) >= 1.0): return -1
    return int(math.log(eps) / math.log(abs(z)))


from math import log

def f(z, eps):

    if z==0 or z==1 or (abs(z)**2<min([1,eps])): return 1
    elif abs(z)>=1: return -1
    else: return int(log(eps)/log(abs(z)))

def f(z, eps, n=1):
    if abs(z) >= 1: return -1
    while abs(z ** n) >= eps: n += 1
    return n

from math import log

def f(z, eps):
    return int(log(eps) / log(abs(z))) if abs(z) < 1 else -1

import math

def f(z, eps):
    return max(-1, math.log(eps)/math.log(math.hypot(z.real, z.imag)))

f=lambda z,e:-(abs(z)>=1)or __import__('math').log(e,abs(z))//1

from math import *

def f(z, eps):
    x,y = z.real,z.imag
    return max(-1,log(eps)/log(hypot(x,y)))

def f(z, eps):
    import math
    if z ==1:
        return 1
    elif abs(z)>=1:
        return -1
    else:
        n=1
        while abs(z)**(n) > eps:
            n+=1
        return n
        


import math
def f(z, eps):
    tmp = math.log(eps, abs(z))
    return math.trunc(tmp) if tmp>0 else -1

def f(z, eps):
    if abs(z) >= 1:
        return -1
    
    n = 1
    while abs(z**n) > eps:
        n += 1
    
    return n