Discuss / Python / 杨辉三角

杨辉三角

Topic source

张文范

#1 Created at ... [Delete] [Delete and Lock User]

def triangles(): list =[] while True: a,b = 0,0 newlist = [] for x in list: a = b b = x newlist.append(a+b) newlist.append(1) list = newlist yield newlist

张文范

#2 Created at ... [Delete] [Delete and Lock User]
def triangles():
    list =[]
    while True:
        a,b = 0,0
        newlist = []
        for x in list:
            a = b
            b = x
            newlist.append(a+b)
        newlist.append(1)
        list = newlist
        yield newlist

  • 1

Reply