In a section of a personal PHP project, I would like to calculate the spending factor in a rule where we spend Nth time the previous payment done.
Here is an example of spending.
firstPaymentAmount=10 SpendingFactor=5 PaymentCount=4 payment1: 10 payment2: 50 (= 10 x 5) payment3: 250 (= 50 x 5) payment4: 1250 (= 250 x 5)
At the end, we're getting the sum of all payments made and we have :
10 + 50 + 250 + 1250 = 1560
I would like to know the formula that let me retrieve the spending factor (=5 here) by only knowing these parameters:
paymentCount = 4 initalPayment = 10 totalPaid = 1560
By knowing the formula to calculate the spendingFactor, I will then be able to know the amount and details of each payment.