Discuss / Python / 成功了

成功了

Topic source

#1 Created at ... [Delete] [Delete and Lock User]
def triangles():
    res = []
    c = 1    while True:
        ch = []
        for i in range(c):
            if i == 0:
                ch.append(1)
            elif i == c - 1:
                ch.append(1)
            else:
                ch.append(res[c - 2][i - 1] + res[c - 2][i])
        yield ch
        res.append(ch)
        c = c + 1

  • 1

Reply