Discuss / Python / 作业。

作业。

Topic source
# -*- coding: utf-8 -*-
def triangles(max):
    n,b = 0,[1]
    while n < max:
        yield b
        b=[1] + [b[m]+b[m+1] for m in range(len(b)-1)]+[1]
        n+=1 
    return 'done'

  • 1

Reply