python杨辉三角实现

def triangles(n):
    L=[1]
    while n>0:
        n=n-1
        yield L
        L.append(0)
        L=[L[i-1]+L[i] for i in range(len(L))]
    
for n in triangles(6):
    print(n)

 

posted @ 2018-04-02 21:54  Horse-Ma  阅读(233)  评论(0编辑  收藏  举报