杨辉三角

def triangles():
prev_line = [1]
while True:
yield prev_line
result = [1]
if len(prev_line) == 1:
result.append(1)
if len(prev_line) > 1:
for i in range(len(prev_line)-1):
result.append(prev_line[i]+prev_line[i+1])
result.append(1)

prev_line = result
posted @ 2018-05-16 14:50  Benguoby2  阅读(80)  评论(0编辑  收藏  举报