Discuss / Python / 作业

作业

Topic source

relative660

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

def triangles(): L=[] while True: if len(L)==0: L=[1] elif len(L) == 1: L=[1,1] else: L0=L[:] L=[1,1] for idx,val in enumerate(L0): if(idx != len(L0)-1): L.insert(-1,L0[idx+1]+val) yield L


  • 1

Reply