No, $p$ is a constant by assumption. Two simple thoughts: the additional $105$ charged each month just has to be added to the payment to pay off the loan if you don't charge any more, so you can solve the problem without the $105$ and add it in at the end. Don't be so quick to put in the value of $i$. You will save yourself a lot of typing and at the end have a formula that you can use for other values of $i$. You might see problems like this again.
Your first line under the solution to this equation is wrong. Increasing $p$ will increase $a_t$, which cannot be right. What you should do is write the equation you did for $a_0$ but without setting $p=0$. Then write the equation $a_{24}=0$ for the two year term. That gives you two equations in two unknowns $c,p$ that you can solve. For the four year term, change it to $a_{48}=0$
Okay:
Formula: $n = -(1/30) \cdot \ln(1+b/p(1-(1+i)^{30})) / \ln(1+i)$
First problem
n = 40
b = 7500
p = 250
i = APR/365; we will solve for APR
plug those in
$ 40 = -(1/30) \cdot \ln(1+7500/250(1-(1+APR/365)^{30})) / \ln(1+APR/365) =-(1/30) \cdot \ln(1+30(1-(1+APR/365)^{30}))/ \ln(1+APR/365)$
multiply both side by 30 and then by $ \ln(1+APR/365)$
$1200 = -\ln(1+30(1-(1+APR/365)^{30}))/ \ln(1+APR/365)$
$1200\ln(1+APR/365) = \ln(1+30(1-(1+APR/365)^{30}))$
We get rid of the $ln$s by rising e to both powers. (Trust me, the e's will vanish.)
$e^{1200\ln(1+APR/365)} = e^{-\ln(1+30(1-(1+APR/365)^{30}))} $
$(e^{\ln(1+APR/365)})^{1200} = (e^{\ln(1+30(1-(1+APR/365)^{30}))})^{-1} $
$(1+APR/365)^{1200} = (1+30(1-(1+APR/365)^{30}))^{-1}= \frac{1}{(1+30(1-(1+APR/365)^{30}))} $
Okay, there's no way in heck I'm going to deal with 1200 roots. So I'm going to cheat.
By the binomial theorem we know $(1 + x)^n = 1 + nx + n(n-1)/2*x^2 + ....$ and if x is very small all the x^i terms will become so small as to be insignificant. So I can estimate $$(1 + x)^n = 1 + nx$ (but only for very small values of x.) Now APR/365 will be a very small number. So I will approximate $(1 + APR/365)^{1200} = 1 + 1200APR365$ and $(1 + APR/365)^{30} = 1 + 30APR365$. So:
$1+1200APR/365 = \frac{1}{(1+30(1-(1+30APR/365)))} = \frac{1}{1+30(-30APR/365)}= \frac{1}{1-900APR/365}$
Multiply both sides by $(1-900APR/365)$
$(1+1200APR/365)(1-900APR/365) = 1$
Pour yourself a stiff drink and expand:
$1 + 1200APR/365 - 900APR/365 - 1200*900(APR/365)^2 = 1$
$1200*900(APR/265)^2 = 300APR/365$
We will assume APR isn't 0 so we divide both sides by $300APR/365$ to get
$1200*900(APR/365)^2/(300APR/365) = 1$
$360000APR/365 = 1$
so
APR = 365/360000 = 0.00101388888888888888888888888889 = 1.01%
Unless I made an error which I almost certainly did. SHEESH
Best Answer
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.