iterative tribonacci python

Solutions on MaxInterview for iterative tribonacci python by the best coders in the world

showing results for - "iterative tribonacci python"
Mariana
18 May 2017
1def trib_iter(m):
2    lista=[m]
3    c=0
4    d=True
5    while d==True:
6        novalista=[]
7        for n in lista:
8            if n in [0,1,2]:
9                c+=1
10            else:
11                for i in range(1,4):
12                    if n-i in [0,1,2]:
13                        c+=1
14                    else:
15                        if n-i<0:
16                            pass
17                        else:
18                            novalista.append(n-i)
19        if novalista==[]:
20            d=False
21        else:
22            lista=novalista
23    return c
24