Let [tex]S[/tex] denote the sum in question:
[tex]S=p+(p+1)+\cdots+(q-1)+q[/tex]
Reorder the terms as
[tex]S=q+(q-1)+\cdots+(p+1)+p[/tex]
Note that each corresponding term in the sums add to [tex]p+q[/tex]:
[tex]p+q=p+q[/tex]
[tex](p+1)+(q-1)=p+q[/tex]
and so on.
So adding both sums together gives
[tex]2S=(p+q)+(p+q)+\cdots+(p+q)+(p+q)[/tex]
There are [tex]p-q+1[/tex] instances of [tex]p+q[/tex]. ([tex]p-q[/tex] is the difference between the first and last terms of the sum, i.e. the number of terms after [tex]p[/tex] to count up to [tex]q[/tex]. Adding 1 will include [tex]p[/tex] in the count.) So,
[tex]2S=(p-q+1)(p+q)[/tex]
[tex]\implies S=\dfrac{(q+p)(q-p+1)}2[/tex]