Shahid Karimi
Shahid Karimi

Reputation: 4357

Dynamic Discount on Products

In the real world the discount on products you purchase is quite interesting. For example a seller offers a discount on his products in the following way:

What is the best way to accomplish this in an eCommerce application?

Upvotes: 2

Views: 441

Answers (1)

Alexei Polkhanov
Alexei Polkhanov

Reputation: 599

Take a ceiling function of the exponent or approximation thereof. For example Discount = MaxDiscount * (1 - (N-1)/N), where N is number of items. for 1 item discount is 0, for 2 items discount is 1/2 of the max, for large number of item it will approach MaxDiscount. Use ceiling function to you want discount to be integer number.

Upvotes: 1

Related Questions