I am currently self-studying logarithms and exponential equations and the book I am using includes the method of calculating different aspects of the compound interest (compounded amount, starting amount, running time, rate of interest), all other aspects being given.
But the number of interest periods per year is never the unknown in any problem, and the book doesn't deal with solving for it, all other aspects known. In short, my question would be:
How do I find the number of interest periods per year, mathematically how do you solve for $x$ in the equation $$\left(\frac{A}{P}\right)^{(rn)^{-1}}=\left(1+\frac 1x\right)^x$$ all other letters known, or simply solve for $x$ in $$c=\left(1+\frac 1x\right)^x$$
Here is my attempt
- $A$ is the compounded amount
- $P$ the principal or starting amount
- $r$ the annual rate of interest
- $n$ the time of compounding in years
- $p$ the number of interest periods annually, and for example it equals $1$ if the compounding happens annually, $2$ if semi-annually, $4$ if quarterly, but this is what we are actually looking for.

In general, there is no closed-form for this solution in terms of high-school-level mathematics.
Solve for $x$ in $$ \left(1+\frac{1}{x}\right)^x = c,\qquad c>1 $$ An answer in terms of the Lambert W function
$$ x = \frac{-\ln(c)}{W_{-1}(-\ln(c)/c)+\ln(c)} $$
See the link for information on the Lambert W function.