Q: Consecutive odd integers and primes Let $n_1,n_2,\ldots n_k$ be a sequence of $k$ consecutive odd integers. If $n_1+n_2+n_3=p_3$ and $n_k+n_{k−1}+n_{k−2}+n_{k−3}+n_{k−4}=q_4$ where both $p$ and $q$ are prime, what is k?
I found in previous answers the equations below, can anyone explain to me how this has been found?
the first sum can be written as $3n_1+6=p_3$
the second sum can be written as $5n_k−20=q_4$.
the second sum is also $5n_1+10k−30=q_4$
Thank you

A: Let $B = n_1$. Then $n_j = B + 2(j-1)$ and we can compute $$p = n_1 + n_2 + n_3 = (B) + (B+2) + (B+4) = 3B+6.$$
and
$$\begin{align}
&\quad \, \, \, n_k + n_{k-1} + n_{k-2} + n_{k-3} + n_{k-4} \\
&= (B + 2(k-1)) + (B + 2(k-2)) + (B + 2(k-3)) + (B + 2(k-4)) + (B + 2(k-5)) \\
&= 5B + 10k - 2 - 4 - 6 - 8 - 10 \\
&= 5B + 10k - 30
\end{align}$$
Let's first use the equation $p = 3B+6$. We can factor $3B+6 = (3)(B+2)$. But we know $p$ is prime, so the only way to factor it into positive integers is $p \cdot 1$. That means we must have $p = 3$ and $B+2 = 1$ and thus $B=-1$. In other words, our sequence of consecutive odd integers must start like $-1, 1, 3, \cdots$ and the sequence of odd integers that are summing up to $p$ is $-1, 1, 3$.
Next, let's use $q = 5B + 10k - 30$. Again we can factor this: $q = (5) (B + 2k - 6)$. We know $q>0$ and $5>0$, so we must have $B+2k-6>0$ too. We know $q$ is prime, so the only way to factor it into positive integers is $q \cdot 1$. That means we must have $q = 5$ and $B+2k-6 = 1$. From above we already know $B=-1$, so we have $-1 + 2k - 6 = 1$ and thus $k = 4$. The sequence of odd numbers adding up to $q$ is $(-3, -1, 1, 3, 5)$.

A: This is much easier than the first posted answer might suggest. If we represent $n_1+n_2+n_3$ as $(n_2-2)+n_2+(n_2+2)$, then we find immediately that $3n_2=p_3$. But $3n_2$ has two explicit factors and $p_3$ is given to be prime, requiring $n_2=1$
By similar set up and reasoning, we can establish that $5n_{k-2}=q_4$, requiring $n_{k-2}=1$
Now we see that $n_2=1=n_{k-2}$, which implies that $k-2=2$, and $k=4$, which is the answer to the question asked.
No need to solve for the specific sequences in each condition.
THIS IS A COMMENT ADDED IN REPLY TO THE COMMENT OF STEVEN STADNICKI, BUT IT IS TOO LONG TO FIT IN A COMMENT BOX
Syntactically, it is quite difficult to understand what OP is primarily interested in. A problem is presented which ends in a question ("what is $k$?"), then a further question is posed predicated on an answer to the original problem. Logically, the further question cannot be the primary question, as it presumes a posted answer to the primary question, which is the question I address in my answer, and indeed is the problem addressed in the first posted answer.
In any event, the approach in the first posted answer is incomplete because the original question ("what is $k$?") arises from a problem which is paradoxically both underspecified and overspecified, and may (if strictly read) have no solutions.
It is underspecified in that it never states that the sequence of odd numbers is increasing. The solution $n_1=-1$ and $n_k=5$ with a difference between terms of $2$ is no more correct than the solution $n_1=3$ and $n_k=-3$ with a difference between terms of $-2$ (bear in mind that $n_2=1$ is required; the source of the term $5$ in this descending sequence is discussed below). I suspect that the problem was originally formulated to remind the student that arithmetic sequences are not limited to positive integers. However, once that circumstance comes to mind, the astute student will recall that arithmetic sequences need not be increasing. In order to be complete, the method should be repeated using the equations $3n_1-6=p_3$ and $5n_k+20=q_4$ to ensure that the same value of $k$ is obtained in both cases (it is).
The problem is overspecified because it is rooted specifically in the odd numbers, when the answer $k=4$ is obtained for any arithmetic sequence which affords a solution. This is plain from the answer I provided, where the middle term of each sequence must be $1$, regardless of the magnitude of the differences between terms or whether that difference is positive or negative. The original problem can be stated as relating to any arithmetic sequence, rather than the specific sequence of odd numbers.
One final observation: The original problem specifies a sequence beginning with $n_1$ and running to $n_k$. The actual solution (however arrived at) implies that there must be a term $n_0$ (which is either $-3$ or $5$) in order to solve for $q_4$; i.e. if $k=4$, then $n_{k-4}$ must be $n_0$, which term is not within the sequence as postulated. Hence, as it is stated, the original problem is strictly speaking impossible to solve.
