def triangles(max): n=1 t1=[0,1] t2=[1,0] while n <= max: b=1 yield (t1[1:]) while b <= n+1: t1[b-1]=t1[b-1]+t2[b-1] t2[b-1]=t1[b-1] b=b+1 t1.insert(0,0) t2.append(0) n = n+1
Sign in to make a reply
学而时习之