Let sequence $\{d_{n}\}$ ,Now give the postive integer $p$,let $d_{n}=\gcd(n^2+p,(n+1)^2+p)$.show that $\{d_{n}\}$ is periodic.and find the $d_{n}$ value of the possible ?
since $$d_{n}=\gcd(n^2+p,(n+1)^2+p-n^2-p)=(n^2+p,2n+1)$$
Let sequence $\{d_{n}\}$ ,Now give the postive integer $p$,let $d_{n}=\gcd(n^2+p,(n+1)^2+p)$.show that $\{d_{n}\}$ is periodic.and find the $d_{n}$ value of the possible ?
since $$d_{n}=\gcd(n^2+p,(n+1)^2+p-n^2-p)=(n^2+p,2n+1)$$
Note: The original question was to determine if $d_n =\gcd(a_{n}+p,a_{n+1}+p)$ is periodic, where $p$ is positive integer while $(a_n)$ satisfies
$$ a_{n+1}=2a_{n}-{a_{n-1}}+\frac{1}{n}(a_{n}-a_{n-1}+1),\ a_1 = 1,\ a_2 = 4.$$
Feel free to skip this part.
Define $b_n = a_{n+1} - a_n + 1$. Then $b_1 = 4$ and relation $(1)$ becomes
$$ b_n = b_{n-1} + \frac 1n b_{n-1} = \frac{n+1}n b_{n-1} = \frac{n+1}n\cdot\frac n{n-1}\cdots \frac 43\cdot\frac 32 b_1 = 2(n+1)$$ which implies that $a_{n+1}-a_n = 2n + 1$. If we remember formula $\sum_{k=0}^{n-1}(2k+1) = n^2$, we immediately see that $a_n = n^2.$ Thus, $$d_n=\gcd(n^2+p,(n+1)^2+p)$$
We use known formula $\gcd(a,b) = \gcd(a-b,b)$ to get:
$$d_n=\gcd(n^2+p,2n+1)$$ and because $2n+1$ is odd, we have $$d_n=\gcd(2(n^2+p),2n+1) = \gcd(2p-n,2n+1) = \gcd(2p-n,4p+1)\tag{1}$$
where the second equality is due to $$2(n^2+p) = n(2n+1)+2p-n,$$ while the third one is due to $$2n+1=-2(2p-n)+4p+1.$$
Formula $(1)$ gives us a lot. First of all, we can see that $d_n\mid 4p+1$, for all $n\in\Bbb N$. Also, we see that $d_n$ is periodic with period $4p+1$:
$$d_{n+4p+1} = \gcd(2p-n-(4p+1),4p+1) = \gcd(2p-n,4p+1) = d_n.$$
Furthermore, $d_{2p} = 4p+1$ and if $d\mid 4p+1$, $d\neq 4p+1$, then $$d_{2p+kd} = \gcd(2p-(2p+kd),4p+1) = \gcd(kd,4p+1) = d$$ when $\gcd(k,4p+1) = 1$ so every divisor $d$ of $4p+1$ will occur in sequence $(d_n)$ with period $d$ (with exception when greater divisor should "occupy the same spot", which occurs whenever we have $\gcd(k,4p+1) \neq 1$). Also, the sequence is symmetrical around $2p$, since $$d_{2p-k} = \gcd(k,4p+1)=\gcd(-k,4p+1) = d_{2p+k}.$$
To visualize these patterns, here are first $90$ terms when $p=11$ (starting with $d_0$):
$$1, 3, 5, 1, 9, 1, 1, 15, 1, 1, 3, 1, 5, 9, 1,\\ 1, 3, 5, 1, 3, 1, 1, 45, 1, 1, 3, 1, 5, 3, 1,\\ 1, 9, 5, 1, 3, 1, 1, 15, 1, 1, 9, 1, 5, 3, 1,\\ 1, 3, 5, 1, 9, 1, 1, 15, 1, 1, 3, 1, 5, 9, 1,\\ 1, 3, 5, 1, 3, 1, 1, 45, 1, 1, 3, 1, 5, 3, 1,\\ 1, 9, 5, 1, 3, 1, 1, 15, 1, 1, 9, 1, 5, 3, 1$$
Observe that $4p+1 = 45$ which occurs as $d_{2p}$, $3$ occurs with period $3$, except on places where $9$ is, when $3$ and $5$ overlap, we get $15$ instead, etc.