# Generating a sequence

#### MarkFL

Staff member
It can be shown that when $5n+1$ and $7n+1$ (where $n\in\mathbb{N}$) are both perfect squares, then $n$ is divisible by $24$.

Find a method for generating all such $n$.

#### Opalg

##### MHB Oldtimer
Staff member
It can be shown that when $5n+1$ and $7n+1$ (where $n\in\mathbb{N}$) are both perfect squares, then $n$ is divisible by $24$.

Find a method for generating all such $n$.
Partial solution:
If $5n+1=p^2$ and $7n+1=q^2$ then $35n+7 = 7p^2$ and $35n+5 = 5q^2$. Subtract, to get $7p^2 - 5q^2 = 2$. That is a Diophantine equation, which you can solve by looking at the continued fraction expansion of $\sqrt{5/7}$. If the $k$th solution is $(p_k,q_k)$, then the first few solutions, with the corresponding values $n_k$ of $n$ are $$\begin{array}{c|c|c|c}p_k&q_k&n_k&n_k/24 \\ \hline 1&1&0&0 \\ 11&13&24&1 \\ 131 & 155 & 3432 & 143 \\ 1561 & 1847 & 487344 & 20306 \\18601 & 22009 & 69199440 & 2883310 \end{array}$$

The numbers $p_k$ satisfy the recurrence relation $p_k = 12p_{k-1} - p_{k-2}$, and $q_k$ satisfies the same recurrence relation. That enables you to generate all the values of $n$, but I have not been able to find an explicit formula for $n_k.$

#### MarkFL

Staff member
Partial solution:
If $5n+1=p^2$ and $7n+1=q^2$ then $35n+7 = 7p^2$ and $35n+5 = 5q^2$. Subtract, to get $7p^2 - 5q^2 = 2$. That is a Diophantine equation, which you can solve by looking at the continued fraction expansion of $\sqrt{5/7}$. If the $k$th solution is $(p_k,q_k)$, then the first few solutions, with the corresponding values $n_k$ of $n$ are $$\begin{array}{c|c|c|c}p_k&q_k&n_k&n_k/24 \\ \hline 1&1&0&0 \\ 11&13&24&1 \\ 131 & 155 & 3432 & 143 \\ 1561 & 1847 & 487344 & 20306 \\18601 & 22009 & 69199440 & 2883310 \end{array}$$

The numbers $p_k$ satisfy the recurrence relation $p_k = 12p_{k-1} - p_{k-2}$, and $q_k$ satisfies the same recurrence relation. That enables you to generate all the values of $n$, but I have not been able to find an explicit formula for $n_k.$
Good work, Opalg! I was not necessarily asking for a closed form solution; a recursive algorithm fits the bill for finding a method to generate the sequence. I will post my solution within 24 hours. #### MarkFL

Staff member
My solution:

Let:

(1) $$\displaystyle 5n+1=p^2$$

Since both squares have the same parity, their difference is even, and so we may let:

(2) $$\displaystyle 7n+1=(p+2k)^2$$ where $$\displaystyle k\in\mathbb{N}$$

Subtracting (1) from (2), we obtain:

$$\displaystyle 2n=(p+2k+p)(p+2k-p)=4k(p+k)$$

$$\displaystyle n=2k(p+k)$$

Substituting for $n$ into (1), we have:

$$\displaystyle 5(2k(p+k))+1=p^2$$

$$\displaystyle p^2-10kp-\left(10k^2+1 \right)=0$$

Taking the positive root for $p$, we obtain:

$$\displaystyle p=5k+\sqrt{35k^2+1}$$

A sequence defined recursively by:

$$\displaystyle A_{n+1}=sA_{n}+tA_{n-1}$$

will have limiting values of:

$$\displaystyle L=\lim_{n\to\pm\infty}\frac{A_{n+1}}{A_{n}}=\frac{s\pm\sqrt{s^2+4t}}{2}$$

Observing that for $$\displaystyle s=12,t=-1$$ we have:

$$\displaystyle L=\lim_{n\to\pm\infty}\frac{A_{n+1}}{A_{n}}=6\pm \sqrt{35}$$

Thus, we find $p$ may be given in closed form by:

$$\displaystyle p_{m}=c_1\left(6+\sqrt{35} \right)^m+c_2\left(6-\sqrt{35} \right)^m$$ where $p_0=1,\,p_1=11$

The initial values are obtained from $n=0,\,24$. We may now determine the parameters $c_i$ from the initial values:

$$\displaystyle p_{0}=c_1+c_2=1\,\therefore\,c_2=1-c_1$$

$$\displaystyle p_{1}=c_1\left(6+\sqrt{35} \right)+\left(1-c_1 \right)\left(6-\sqrt{35} \right)=11$$

Hence:

$$\displaystyle c_1=\frac{7+\sqrt{35}}{14},\,c_2=\frac{7-\sqrt{35}}{14}$$

And so we have:

$$\displaystyle p_{m}=\frac{1}{14}\left(\left(7+\sqrt{35} \right)\left(6+\sqrt{35} \right)^m+\left(7-\sqrt{35} \right)\left(6-\sqrt{35} \right)^m \right)$$

Now, using the relationship between $n$ and $p$ in (1), we have:

$$\displaystyle n=\frac{p^2-1}{5}$$

Hence:

$$\displaystyle n_m=\frac{\left(\frac{1}{14}\left(\left(7+\sqrt{35} \right)\left(6+\sqrt{35} \right)^m+\left(7-\sqrt{35} \right)\left(6-\sqrt{35} \right)^m \right) \right)^2-1}{5}$$

#### alane1994

##### Active member
And this is yet another example of why I am an engineering major...
Sorry for interrupting with a somewhat "useless" post. Carry on.

#### MarkFL

Staff member
And this is yet another example of why I am an engineering major...
Sorry for interrupting with a somewhat "useless" post. Carry on.
Difference equations...they're comin' for ya...   #### Klaas van Aarsen

##### MHB Seeker
Staff member
And this is yet another example of why I am an engineering major...
Sorry for interrupting with a somewhat "useless" post. Carry on.
Weren't you posting problems with differential equations?
I found this post by masters rather funny and very true.
Sorry for another interrupting an somewhat useless post. 