def    npv(ico, nci, r, n):
    """ This capital budgeting function computes the net present
    value on a cash flow generating investment.
    ico = Initial Capital Outlay
    nci = net cash inflows per period
    r = discounted rate
    n = number of periods
    Example: npv(100000, 15000, .03, 10)
    """
    pv_nci = 0
    for x in range(n):
        pv_nci = pv_nci + (nci/((1 + r) ** (x + 1)))
    return pv_nci - ico