def annuity_factor(n, i):
    """
    Calculate annuity factor

    Args:
        n: depreciation period (40 = 40 years)
        i: interest rate (0.06 = 6%)
    Returns:
        annuity factor derived by formula (1+i)**n * i / ((1+i)**n - 1)
    """
    return (1 + i) ** n * i / ((1 + i) ** n - 1)