Discuss / Python / 杨辉三角

杨辉三角

Topic source
def triangles():
    Last = [1]
    yield Last        
    while 1:
        L = [1]        
        for x in range(1,len(Last)):
                L.append(Last[x-1]+Last[x])
        L.append(1)    
        Last = L[:]    
        yield L

  • 1

Reply