def construct(n , U = None):
    if not U:
        U = [ (1,2,3) ] + [ (None,None,None) ] * n
    if n == 0:
        return (1, 2, 3)
    else:
        Uprec = construct(n-1 , U)
        u, v, w = Uprec[0], Uprec[1], Uprec[2]
        u_next = u + v - w
        v_next = u - v + w
        w_next = (u - v) / w
        U += [ (u_next , v_next , w_next) ]
        return U[-1]

print( construct(7) )