Closed form of recurrence with two inputs
The candle burning rules are as follows: if you have c&gt;=m candles, you can remove (m-1) of them and score m points while doing so. If you have fewer than c&lt;m candles, then you score c points and are then done.
The total number of points you can score are then the points you score at the end (c % (m-1)), and the number of points you score before then (m * (c // (m-1))).