common ratio of a geometric sequence formed from three terms of an arithmetic sequence The problem is to prove that if we have an arithmetic sequence and we choose $3$ numbers from it which form a geometric sequence as well, and also in the new geometric sequence these $3$ numbers are after each other with no gap, the common ratio ($r$) can be calculated like this:
$A(m),A(n)$ & $A(p)$ are the chosen numbers, so the common ratio is $= \dfrac{p-n}{n-m}$
Please help me prove it!
Here is the original question in Persian:

 A: Let $(a_k)$ be an arithmetic sequence with initial term $a_1$ and common difference $d$.  Then its $k$th term is given by $a_k = a_1 + d(k - 1)$.  Hence,
\begin{align*}
a_m & = a_1 + d(m - 1)\\
a_n & = a_1 + d(n - 1)\\
a_p & = a_1 + d(p - 1)
\end{align*}
Since $a_m, a_n, a_p$ are successive terms of a geometric sequence with common ratio $r$,
$$r = \frac{a_p}{a_n} = \frac{a_n}{a_m}$$
since $r = \dfrac{a_{k + 1}}{a_k}$ for each positive number $k$.  Substituting for $a_m, a_n,$ and $a_p$ yields
$$r = \frac{a_1 + d(p - 1)}{a_1 + d(n - 1)} \tag{1}$$
and
$$r = \frac{a_1 + d(n - 1)}{a_1 + d(m - 1)} \tag{2}$$
If we multiply both sides of equation $1$ by $a_1 + d(n - 1)$, we obtain
\begin{align*}
ra_1 + rd(n - 1) & = a_1 + d(p - 1)\\
ra_1 + nrd - rd & = a_1 + pd - d \tag{3}\\
\end{align*}
If we multiply both sides of equation $2$ by $a_1 + d(m - 1)$, we obtain
\begin{align*}
ra_1 + rd(m - 1) & = a_1 + d(n - 1)\\
ra_1 + mrd - rd & = a_1 + nd - d \tag{4}
\end{align*}
Subtracting equation $4$ from equation $3$ yields
$$nrd - mrd = pd - nd$$
If $d \neq 0$, we obtain
\begin{align*}
nr - mr & = p - n\\
(n - m)r & = p - n\\
r & = \frac{p - n}{n - m}
\end{align*}
which is valid if the arithmetic sequence is not constant.
If $d = 0$, both sequences are constant, and the claim fails to hold.  For instance, let $(a_k)$ be the arithmetic sequence with $a_1 = 1$ and $d = 0$.  Then $a_k = 1$ for each positive integer $k$, so $a_1 = a_2 = a_6 = 1$ and $r = 1$, but
$$r = 1 \neq \frac{6 - 2}{2 - 1} = \frac{4}{1} = 4$$
