Solution:
The property clearly holds whenever p(x) is a constant polynomial, since we can take q(x)=x. Assume henceforth that p(x) is nonconstant and has the stated property. Let d be the degree of p(x), so p(x) is of the form
p(x)=cxd+⋯.
By a Lemma (which we will prove at the end), ∑k=1nkd is a polynomial in n of degree d+1, so p(1)+p(2)+⋯+p(n) is a polynomial in n of degree d+1. Hence, q(n) is a polynomial of degree 1. Furthermore, the coefficient of nd+1 in ∑k=1nkd is d+11, so the coefficient of n in q(n) is also d+11. Let q(x)=d+11(x+r). We have that
p(1)+p(2)+p(3)+⋯+p(n)=p(n)q(n)
and
p(1)+p(2)+p(3)+⋯+p(n)+p(n+1)=p(n+1)q(n+1).
Subtracting the first equation from the second, we get
p(n+1)=p(n+1)q(n+1)−p(n)q(n),
and hence
p(n)q(n)=p(n+1)[q(n+1)−1].
Since this holds for all positive integers n, it follows that
p(x)q(x)=p(x+1)[q(x+1)−1]
for all real numbers x. We can then write
p(x)⋅d+11(x+r)=p(x+1)[d+11(x+r+1)−1]
so
(x+r)p(x)=(x+r−d)p(x+1).
Setting x=−r, we get
(−d)p(−r+1)=0
Hence, −r+1 is a root of p(x). Let p(x)=(x+r−1)p1(x). Then
(x+r)(x+r−1)p1(x)=(x+r−d)(x+r)p1(x+1),
so
(x+r−1)p1(x)=(x+r−d)p1(x+1).
If d=1, then p1(x) is a constant, so both sides are equal, and we can say p(x)=c(x+r−1).
Otherwise, setting x=−r+1, we get
(1−d)p1(−r+2)=0
Hence, −r+2 is a root of p1(x). Let p1(x)=(x+r−2)p2(x). Then
(x−r−1)(x+r−2)p2(x)=(x+r−d)(x+r−1)p2(x+1),
so
(x+r−2)p2(x)=(x+r−d)p2(x+1).
If d=2, then p2(x) is a constant, so both sides are equal, and we can say p(x)=c(x+r−1)(x+r−2).
Otherwise, we can continue to substitute, giving us
p(x)=c(x+r−1)(x+r−2)⋯(x+r−d).
Conversely, if p(x) is of this form, then
p(x)====c(x+r−1)(x+r−2)⋯(x+r−d)d+1c(d+1)(x+r−1)(x+r−2)⋯(x+r−d)d+1c[(x+r)−(x+r−d−1)](x+r−1)(x+r−2)⋯(x+r−d)d+1c(x+r)(x+r−1)(x+r−2)⋯(x+r−d)−d+1c(x+r−1)(x+r−2)⋯(x+r−d)(x+r−d−1).
Then the sum p(1)+p(2)+p(3)+⋯+p(n) telescopes, and we are left with
p(1)+p(2)+p(3)+⋯+p(n)=d+1c(n+r)(n+r−1)(n+r−2)⋯(n+r−d)−d+1c(r)(r−1)⋯(r−d+1)(r−d).
We want this to be of the form
p(n)q(n)=c(n+r−1)(n+r−2)⋯(n+r−d)q(n)
for some polynomial q(n). The only way that this can hold for each positive integer n is if the term
d+1c(r)(r−1)⋯(r−d+1)(r−d)
is equal to 0 . This means r has to be one of the values 0,1,2,…,d. Therefore, the polynomials we seek are of the form
p(x)=c(x+r−1)(x+r−2)⋯(x+r−d)
where r∈{0,1,2,…,d}.
Lemma. For a positive integer d,
k=1∑nkd
is a polynomial in n of degree d+1. Furthermore, the coefficient of nd+1 is d+11.
Proof. We prove the result by strong induction. For d=1,
k=1∑nk=21n2+21n
so the result holds. Assume that the result holds for d=1,2,3,…,m, for some positive integer m. By the Binomial Theorem,
(k+1)m+2−km+2=(m+2)km+1+cmkm+cm−1km−1+⋯+c1k+c0,
for some coefficients cm,cm−1,…,c1,c0. Summing over 1≤k≤n, we get
(n+1)m+2−1=(m+2)k=1∑nkm+1+cmk=1∑nkm+⋯+c1k=1∑nk+c0n.
Then
k=1∑nkm+1=m+2(n+1)m+2−cm∑k=1nkm−⋯−c1∑k=1nk−c0n−1.
By the induction hypothesis, the sums ∑k=1nkm,…,∑k=1nk are all polynomials in n of degree less than m+2. Hence, the above expression is a polynomial in n of degree m+2, and the coefficient of nm+2 is m+21. Thus, the result holds for d=m+1, which completes the induction step.