def yanghui_triangle(MAX):
print('yanghui_triangle')
L = [1]
n = 1
while n <= MAX:
yield L
L.insert(0,0)
L.append(0)
L_new = [L[:len(L)-1][t] + L[1:len(L)][t] for t in \
list(range(len(L)-1))]
n = n + 1
L = L_new
g = yanghui_triangle(10)
for items in g:
print(items)
雅努斯
def yanghui_triangle(MAX): print('yanghui_triangle') L = [1] n = 1 while n <= MAX: yield L L.insert(0,0) L.append(0) L_new = [L[:len(L)-1][t] + L[1:len(L)][t] for t in \ list(range(len(L)-1))] n = n + 1 L = L_new
g = yanghui_triangle(10) for items in g: print(items)