0
$\begingroup$

I am a programmer interning at a small contract furniture company. This company receives multiple discounts from the manufacturers, and I am trying to calculate the end discount. For example, the first discount is 50%, the second discount is 20% off that price, and the third is 20% of that, then the total discount is 68%. They already have an Excel worksheet that calculates this, but I want to write a recursive function that can perform this calculation as many times as is necessary. My question is; what is this type of discounting called?

$\endgroup$
0
$\begingroup$

This is in general simply referred to as compounding. In functional terms, consider the inefficient python code below

def total_discount(rates):
    return (1.0 - discount(1.0, rates))*100.0

def discount(original, rates):
    if len(rates) == 1:
        return (1.0-rates[0]/100.0)*original
    else:
        return (1.0-rates[0]/100.0)*discount(original, rates[1:])

This type of thing is often seen in forward rates.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.