Discuss / Python / 作业

作业

Topic source
def triangles(max):
    n=1
    t1=[0,1]
    t2=[1,0]
    while n <= max:
        b=1
        yield (t1[1:])
        while b <= n+1:
            t1[b-1]=t1[b-1]+t2[b-1]
            t2[b-1]=t1[b-1]
            b=b+1
        t1.insert(0,0)
        t2.append(0)
        n = n+1

  • 1

Reply