def triangles():
L = [1]
while True:
yield L
# 首尾插入0,方便计算
L1 = [x for x in L]
L1.insert(len(L), 0)
L1.insert(0,0)
L = [value + L1[index - 1] for index, value in enumerate(L1) if index > 0]
Sign in to make a reply
带刺的黄瓜666
def triangles():
L = [1]
while True:
yield L
# 首尾插入0,方便计算
L1 = [x for x in L]
L1.insert(len(L), 0)
L1.insert(0,0)
L = [value + L1[index - 1] for index, value in enumerate(L1) if index > 0]