Discuss / Python / 可行

可行

Topic source

Ashen One

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

def yanghui_triangles():

    row=[1]

    while True:

        yield row

        next_row = [1]

        for step in range(len(row)-1):

            next_row.append(row[step]+row[step+1])

        next_row.append(1)

        row = next_row

solution = yanghui_triangles()

for n in range(101):

    print(next(solution))


  • 1

Reply