Short Problem Definition:
You wish to buy video games from the famous online video game store Mist.
Usually, all games are sold at the same price, p dollars. However, they are planning to have the seasonal Halloween Sale next month in which you can buy games at a cheaper price. Specifically, the first game you buy during the sale will be sold at dollars, but every subsequent game you buy will be sold at exactly d dollars less than the cost of the previous one you bought. This will continue until the cost becomes less than or equal to m dollars, after which every game you buy will cost m dollars each.
time complexity is O(1)
space complexity is O(1)
The solution is based on the Arithmetic Progression. It makes it a bit more complex due to the floor m.
Another option is either a while loop or a recursion.