def annuity_factor(n, i):
    """
    Calculates the annuity factor derived by formula (1+i)**n * i / ((1+i)**n - 1)

    :param n: depreciation period (40 = 40 years)
    :type n: int
    :param i: interest rate (0.06 = 6%)
    :type i: float
    :returns:
        - **a**: annuity factor
    :rtype: float

    """

    a = (1 + i) ** n * i / ((1 + i) ** n - 1)

    return a