def disc(years, percent_rate):
    """Calculate discount rate for a given number of years

        years - an integer number of years
        percent_rate - a discount rate in percent

        returns the discount rate for the number of years to use in
            a calculation like yearly_cost * disc(years, percent_rate)"""

    discount = 0.0
    for time_index in range(int(years) - 1):
        discount += 1.0 / (1.0 + percent_rate / 100.0) ** time_index
    return discount