Consider the following series:

`1, 2, 4, 8, 16, 22, 26, 38, 62, 74, 102, 104, 108, 116, 122`

It is generated as follows:

* For single digit integers, add the number to itself to get the next element.
* For other integers, multiply all the non-zero digits and add the result to the original number to get the next element.

For example: `16 + (6 * 1) = 22` and `104 + (4 * 1) = 108`. 

Let's begin the same series with a seed value of `3` instead of `1`:

`3, 6, 12, 14, 18, 26, 38, 62, 74, 102, 104, 108, 116, 122`

Notice that the two sequences converge at `26` and are identical therefter. We will call the series seeded by a value of `1` the "base series" and the other series the "test series". 

You will be given a seed value for the test series and your task will be to return the number of integers that have to be generated in the test series before it converges to the base series. In the case above:
```Python
convergence(3) = 5, the length of [3, 6, 12, 14, 18]. 
```  

Good luck!

If you like this Kata, please try:

[Simple Prime Streaming](https://www.codewars.com/kata/5a908da30025e995880000e3)

[Unique digit sequence](https://www.codewars.com/kata/599688d0e2800dda4e0001b0)

[Divisor harmony](https://www.codewars.com/kata/59bf97cd4f98a8b1cd00007e)

Difficulty: introductory

Starter code:

def convergence(n):
	

Solutions:
from operator import mul
from functools import reduce

def genSequence(n):
    yield n
    while True:
        n += reduce(mul, [int(d) for d in str(n) if d != '0']) if n > 9 else n
        yield n

def extract(seq, v):
    return sorted(seq).index(v)

def convergence(n):
    gen1, genN = genSequence(1), genSequence(n)
    seq1, seqN = {next(gen1)}, {next(genN)}
    while True:
        a,b = next(gen1), next(genN)
        seq1.add(a)
        seqN.add(b)
        if a in seqN: return extract(seqN, a)
        if b in seq1: return extract(seqN, b)

def next(base):
    mul = 1
    for c in str(base):
        if c!="0":
            mul *= int(c)
    return base + mul
    
def convergence(n):
    base = 1
    test = n
    count = 0
    while test!=base:
        if test > base:
            base = next(base)
        else:
            test =next(test)
            count +=1
        print(str(base)+" "+str(test))
    return count

from functools import reduce

def calculate_next_el(prev_el):
    if prev_el < 10:
        return 2 * prev_el
    else:
        multiplication = reduce((lambda x, y: x * y), [x for x in map(int, str(prev_el)) if x > 0], 1)
        return prev_el + multiplication

def generate_series(start):
    last = start
    while True:
        last = calculate_next_el(last)
        yield last

def convergence(n):
    current_base = 1
    current_test = n
    base_series = generate_series(current_base)
    test_series = generate_series(current_test)
    result = 0
    while current_base != current_test:
        if current_base < current_test:
            current_base = base_series.__next__()
        else:
            current_test = test_series.__next__()
            result += 1
    return result


def sumIntegers(n):
    mod=10
    lst=[]
    while n>0:
        lst.append(n%mod)
        n-=n%mod
        n//=10
    result = 1
    for i in lst:
        if i!=0:
            result*=i
    return result
def convergence(n):
    ntest=1
    i=0
    while True:
        if ntest == n:
            return i
        elif n>ntest:
            ntest = ntest + sumIntegers(ntest)
        else:
            n=n+sumIntegers(n)
            i+=1
        
        
        


import numpy
base=[1]
def convergence(n):
    test=[n]
    while test[-1] not in base:
        if base[-1]>test[-1]:test.append(test[-1]+int(numpy.prod([int(dig) for dig in str(test[-1]) if int(dig)!=int()])))
        else:base.append(base[-1]+int(numpy.prod([int(dig) for dig in str(base[-1]) if int(dig)!=int()])))
    return len(test)-1

from functools import reduce

def convergence(n):
    print(n)
    t,r = [1],[n]
    f = lambda x: x+reduce(lambda x,y:x*y, (int(i) for i in str(x) if i!='0'))
    while r[-1] not in t:
        for _ in range(25):
            t += [f(t[-1])]
        r += [f(r[-1])]
    return len(r)-1

from itertools import accumulate, repeat
from functools import reduce
from operator import mul

value = lambda n: n + reduce(mul, filter(None, map(int, str(n))))
serie = lambda *args: accumulate(repeat(*args), lambda x,_: value(x))
base = set(serie(1, 1000))

def convergence(n):
    return next(i for i,x in enumerate(serie(n)) if x in base)

from functools import reduce
from itertools import count, islice
from operator import mul

def gen(n):
    yield n
    while True:
        n += n if n < 10 else reduce(mul, map(int, str(n).replace('0', '')), 1)
        yield n

def convergence(n, base_series = set(islice(gen(1), 1000))):
    it = gen(n)
    return next(i for i in count() if next(it) in base_series)

from operator import mul
from functools import reduce

# generate base series
base, n = {1}, 1
for _ in range(2000):
    n += reduce(mul, map(int, str(n).replace("0", "")))
    base.add(n)


def convergence(n):
    steps = 0
    
    while n not in base:
        n += reduce(mul, map(int, str(n).replace("0", "")))
        steps += 1
    
    return steps

from functools import reduce
def convergence(n):
    j = 0
    x = 1
    s1 = set()
    s2 = set()
    while True:
        s1.add(x)
        s2.add(n)
        if x in s2 or n in s1 or s1.intersection(s2):
            break
        if n < 10:
            n = n + n
        else:
            n = n + reduce(lambda h,k: h*k, (int(i) for i in str(n) if i!="0"))    
        if x < 10:
            x = x + x 
        else:
            x = x + reduce(lambda h,k: h*k, (int(i) for i in str(x) if i!="0"))
    return sorted(list(s2)).index(list(s1.intersection(s2))[0])