Discuss / Python / 感觉写得很菜

感觉写得很菜

Topic source

def YangTriangles(max): n=1 b=[1,] while n<=max: yield b b.append(1) if n>1: i=n-1 while i>0: b[i]=b[i-1]+b[i] i=i-1 n=n+1 return 'done'

b=YangTriangles(10) for n in b: print(n)


  • 1

Reply