Discuss / Python / 杨辉三角

杨辉三角

Topic source

Pop_林肥強

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

def traingles(): L = [1] while True: yield L L = [L[i] + L[i + 1] for i in range(len(L) - 1)] L.insert(0, 1) L.append(1)

n = 0 for t in traingles(): print(t) n = n + 1 if n == 10: break


  • 1

Reply