def triangles(): res = [] c = 1 while True: ch = [] for i in range(c): if i == 0: ch.append(1) elif i == c - 1: ch.append(1) else: ch.append(res[c - 2][i - 1] + res[c - 2][i]) yield ch res.append(ch) c = c + 1
Sign in to make a reply