To actually solve your problem, you would start out with an unknown amount of $X$ payment per month. This is the variable you care about. In fact, you would program a function where this is your input. You would then program an iterative process that pays the minimum on the two cards with the lower rates and the rest of $X$ on the one with the highest balance, until that one is paid off. Once that one is paid off, you start paying the minimum on the one with 8\% interest and pay all the rest to the one with 10\%. And, you would make payments for 24 months. And, once the the second is paid off, all remaining payments go to the one remaining card.
Now that you have this function programmed, you run it with different values of $X$ until your remaining value is \$0. Use some basic knowledge, such as, if one value of $X$, say $X_1$, gives you a positive balance at the end, and another, say $X_2$, gives you a negative balance at the end, then your answer is somewhere in between.
By the way, in reality, the formula you found is wrong. A 12% annual interest rate does NOT translate into 1% per month. But, maybe that is how they teach things when you first see this stuff.
$$A(t) = A_0 \left( 1 + \frac{r}{n} \right)^{nt}$$
is the formula you can use to find the amount, $A(t)$, at time $t$ if your initial balance is $A_0$, your interest rate is $r$ (given as a decimal, so 12% would be 0.12), and $n$ is the number of payments per month. An annual rate of 12% per year means that if you start with \$100, after 1 year, you will have 12%. A monthly rate of 1% means after 1 month, you would have $100 (1 + .01) = 101$. And, in general, after $k$ months, you'd have $100 (1.01)^k$. So, after 12 months, you'd actually have \$112.68. It's somewhat close, but it's not the same.
To take an annual rate, $r$, and translate it into the appropriate monthly rate, you would want to solve
$$1 + r = \left( 1 + \frac{i}{12} \right)^{12}$$
for $i/12$, which would give you
$$\frac{i}{12} = (1+r)^{1/12} - 1.$$
So, for instance, if your annual rate is 14%, your monthly rate would be
$$\frac{i}{12} = (1.14)^{1/12} - 1 = 0.010978852.$$
This is not the same as 0.14/12 = 0.011666666666.
On the other hand, if you said that your interest rate is 14% compounded monthly, then your monthly rate is in fact 0.14 / 12. It's a matter of knowing the terminology and it is important in reality. Just to be clear, if you say your rate is an annual rate of 14%, then the above calculations are necessary. If you say the rate is 14% compounded monthly, then the monthly rate is 0.14/12.
You have made some numerical errors and considered the contribution of $\$4000$
only. Mathematically one can establish an equivalence between the investments
(at the end of $5$ years and at the end of $10$ years) and a series of $120$
monthly constant payments.
Since there are $m=12$ compounding periods per year, the (nominal) annual interest rate $r=4\%=0.04$ indicates a monthly interest
rate $i=\frac{r}{m}=\frac{4}{12}\%=\frac{0.04}{12}$.
The hypothetical investment of $3000$ at the end of $5$ years ($60$ months) will
accumulate interest during $5$ years ($60$ months). Hence it's future value is $$F^{\prime }=3000\left( 1+i\right)^{60}=3000\left( 1+0.04/12\right) ^{60}\approx 3663.0.$$ Adding the second hypothetical investment $F^{\prime \prime }=4000$ yields the total
future value $F=F^{\prime }+F^{\prime \prime }=7663.0$ at the end of $10$
years. Let $A$ (the annuity) denote each monthly payment. The payment at the end of month $k$ increases to a future value of $F_{k}=A(1+i)^{n-k}$ at the end of $n=120$
months. Summing all these $F_{k}$ the resulting geometric series of $n$
payments, whose ratio is $c=1+i$, should be equal to $F$, as a consequence of the equivalence mentioned above. Applying the formula for such a sum, we get
\begin{equation*}
F=\sum_{k=1}^{n}F_{k}=\sum_{k=1}^{n}A(1+i)^{n-k}=\sum_{j=1}^{n}Ac^{j-1}=A
\frac{c^{n}-1}{c-1}=A
\frac{(1+i)^{n}-1}{i}.
\end{equation*}
Numerically we obtain
\begin{equation*}
A=F\frac{i}{(1+i)^{n}-1}=7663.0\frac{\frac{0.04}{12}}{(1+\frac{0.04}{12}
)^{120}-1}\approx 52.04,
\end{equation*}
which agrees with the answer you indicate.
Best Answer
You compound it $6$ times $$520*\left(1+\frac{0.18}{12}\right)^6$$