Find all positive integers m,n and primes $p\geq5$ such that $m(4m^2+m+12)=3(p^n-1)$ I did it like this. We can manipulate  the equation  to come to
$\frac{(m^2+3)(4m+1)}{3}=p^n$
Now 3 divides either $(m^2+3) or (4m+1) $
If we assume 3 divides $(m^2+3)$ and it is equal to $(4m+1)$ (my intuition) .we get
$\frac{m^2+3}{3}=4m+1$.solving this we get $m=12$ we can substitute  back in equation to get $n=4:p=7$ which is correct. But i am not able to prove that 
$\frac{m^2+3}{3}=4m+1$. 
Please help me to complete my solution
 A: You have that
$$\frac{(m^2+3)(4m+1)}{3}=p^n \tag{1}\label{eq1A}$$
I don't see any particular way to directly prove your assumption that $\frac{m^2 + 3}{3} = 4m + 1$. Instead, here is a proof it's the only solution, so your assumption is true in that manner.
Since both $m^2 + 3$ and $4m + 1$ are $\gt 3$ for positive integers $m$, and they contain just $1$ factor of $3$, then both terms must contain at least one factor of $p$. Let
$$d = \gcd(m^2 + 3, 4m + 1) \tag{2}\label{eq2A}$$
Also, you have that
$$\begin{equation}\begin{aligned}
d \; \mid \; & 16(m^2 + 3) - (4m - 1)(4m + 1) \\
& = 16m^2 + 48 - 16m^2 + 1 \\
& = 49
\end{aligned}\end{equation}\tag{3}\label{eq3A}$$
As $p \mid d$, this means $p = 7$. There are thus $2$ basic possibilities depending on which term has a factor of $3$. First, consider for some positive integers $i,j$ where
$$m^2 + 3 = 3(7^i) \implies m^2 = 3(7^i - 1) \tag{4}\label{eq4A}$$
$$4m + 1 = 7^j \implies m = \frac{7^j - 1}{4} \tag{5}\label{eq5A}$$
From \eqref{eq3A}, you have that
$$\begin{equation}\begin{aligned}
49 & = 16(m^2 + 3) - (4m - 1)(4m + 1) \\
& = 16(3)(7^i) - (7^j - 2)(7^j) \\
& = 48(7^i) - (7^j - 2)(7^j)
\end{aligned}\end{equation}\tag{6}\label{eq6A}$$
Since the left side is $49 = 7^2$, then $i$ and/or $j$ must be $\le 2$ since, otherwise, the right side would have more than $2$ factors of $7$. If $i = 1$, you have $m^2 = 18$, which gives a non-integral $m$. If $i = 2$, then $m^2 = 144 \implies m = 12$, which is the result you already have. For $i \gt 2$, then $j \le 2$, so consider \eqref{eq5A}. For $j = 1$, you get $m = \frac{6}{4}$, which is not an integer. Finally, for $j = 2$, you get $m = 12$, which has already been accounted for.
Next, consider the second factor is a multiple of $3$ instead, i.e., there are some positive integers $k,q$ where
$$m^2 + 3 = 7^k \implies m^2 = 7^k - 3 \tag{7}\label{eq7A}$$
$$4m + 1 = 3(7^q) \implies m = \frac{3(7^q) - 1}{4} \tag{8}\label{eq8A}$$
Now, from \eqref{eq3A}, you have
$$\begin{equation}\begin{aligned}
49 & = 16(m^2 + 3) - (4m - 1)(4m + 1) \\
& = 16(7^k) - (3(7^q) - 2)(3)(7^q)
\end{aligned}\end{equation}\tag{9}\label{eq9A}$$
Similar to before, $k$ and/or $q$ must be $\le 2$. Note $k = 1$ gives $m^2 = 4 \implies m = 2$. However, this means from \eqref{eq8A} that $7^q = 3$, which doesn't give an integral $q$. With $k = 2$, \eqref{eq7A} gives $m^2 = 46$, so $m$ is not an integer. For $k \gt 2$, you have $q \le 2$, so consider \eqref{eq8A}. For $q = 1$, you get $m = 5$. However, from \eqref{eq7A}, you get $7^k = 28$, so $k$ is not an integer. Finally, for $q = 2$, you get $m = \frac{146}{4}$, which is not an integer.
Thus, in summary, there is only the one solution you already found, i.e., $m = 12$, $n = 4$ and $p = 7$.
A: This is a variation on John Omielan's answer, starting with the equation in the form $(m^2+3)(4m+1)=3p^n$. As John notes, each factor $m^2+3$ and $4m+1$ must contain a power of the prime $p$, since $m^2+3$ and $4m+1$ are both greater than $3$ if $m\ge1$.
Now using properties of the $\gcd$ relation, we see that
$$\begin{align}
\gcd(m^2+3,4m+1)
&=\gcd(m^2-12m,4m+1)\\
&=\gcd(m(m-12),4m+1)\\
&=\gcd(m-12,4m+1)\quad\text{(since }\gcd(m,4m+1)=1)\\
&=\gcd(m-12,49)
\end{align}$$
It follows that $p$ can only be $7$, $m$ must be congruent to $5$ mod $7$, and the smaller of the two powers of $7$ is either $7$ or $49$.  Now
$$m^2+3\ge{4m+1\over3}\quad\text{for all }m\ge1$$
so if $3\mid4m+1$ we must have $4m+1=3\cdot7$ or $3\cdot49$.  The former gives $m=5$, for which $m^2+3=28$ is not a power of $7$, while the latter gives $m=146/4$, which is not an integer.  Therefore we must have $3\mid m^2+3$. Now
$${m^2+3\over3}\ge4m+1\quad\text{for }m\ge12$$
Recalling that our gcd analysis showed that $m$ must be congruent to $5$ mod $7$, and that we've already seen that $m=5$ gives $m^2+3=28$, we see that $m=12$ is the only possible solution: $4\cdot12+1=49$ and $12^2+3=147=3\cdot49$.  In sum, $m=12$, $p=7$, and $n=4$ is the only solution (with positive integers $m$ and $n$ and prime $p$) to $m(4m^2+m+12)=3(p^n-1)$.
