def compose_j(n, Nvec):
    """
    Eq. 4 in Poly Fits Derivation. Routine to compose the j counter from
    the n values. Can also be used as Eq. 10 with the i counter and the nhat
    values.
    
    inputs:
    
        n = list of integer values representing the independent variables'
            exponents for the jth term in the multidimensional polynomial
            function (Eq. 2)
        Nvec = list of integers representing the polynomial order of the
            independent variables
    
    returns:
    
        j = integer representing the column of the A matrix or the jth
            polynomial coefficient
    """
    # calculate V
    V = len(Nvec)
    # initialize j to 0
    j = 0
    # loop through independent variables
    for v in range(1,V+1):
        # initialize product series to 1
        prod = 1
        # loop through w values for product series
        for w in range(v+1,V+1):
            # multiply on the term to the product series
            prod *= Nvec[w-1] + 1
        # add on term onto j
        j += n[v-1] * prod
    return j