Can't Generalize gcd summation sequence Given some $k$, and the sequence $A_i = k + i^2$, evaluate:
$$
\sum_{i=1}^{2k}gcd(A_i, A_{i+1})
$$
I ran into this problem in a coding challenge, and it stumped me. I can calculate it the  exhaustive way, iterating through, calculating each GCD, but it just looks like there's some pattern I'm not grasping. I looked a lot at Eurler's totient function, but I could not find any meaningful link. The irregular gaps of the sequence seem to make it difficult.
Properties I have observed (of dubious use):
Consider the series $B_k = f(k)$ where $f(k)$ is the solution to the above problem.
It produces the following graph, where the blue line is $y=6x$

It seems that regularly, the value is equal to $6k$, which I do not understand. The frequency of the points where this is true is not a sequence I (or the OEIS) could recognize.
I really feel like I'm missing something obvious. Any help at is appreciated! Thanks is advance!
 A: The values of $k$ for which the sum equals $6k$ are exactly those for which $4k+1$ is prime.
To see this, note that the last summand equals
$$
\gcd\big(k+(2k)^2,k+(2k+1)^2\big) = \gcd\big(k(4k+1),(k+1)(4k+1)\big) = 4k+1.
$$
Since each of the other $2k-1$ summands are $\ge1$, this shows that $6k$ is a lower bound for the sum. The sequence along the blue line is therefore the set of $k$ such that $\gcd\big(k+i^2,k+(i+1)^2\big)=1$ for all $1\le i\le 2k-1$.
Since $k+(i+1)^2 = (k+i^2)+(2i+1)$, we see that
$$
\gcd\big(k+i^2,k+(i+1)^2\big)=\gcd\big(k+i^2,2i+1\big)=\gcd\big(4k+4i^2,2i+1\big)
$$
(the latter step because $2i+1$ is odd). But now $4k+4i^2 = (4k+1)+(2i-1)(2i+1)$, and so
$$
\gcd\big(4k+4i^2,2i+1\big)=\gcd\big(4k+1,2i+1\big).
$$
The values of $k$ in question are therefore those for which $\gcd\big(4k+1,2i+1\big)=1$ for all $1\le i\le 2k-1$.
But this is easily seen to be equivalent to $4k+1$ being prime.
(Side note: the identity $\gcd\big(k+i^2,k+(i+1)^2\big) = \gcd\big(4k+1,2i+1\big)$ is also probably helpful from an algorithmic standpoint.)
