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))
Sign in to make a reply
Ashen One
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))