Dear student,
Let first term be a and common difference be d.
pth term = a + (p-1)d = q -----(i)
qth term = a + (q-1)d = p -----(ii)
(ii) - (i) gives:
(q - p)d = p - q
or d = -1
(i) gives a = q - (p-1)d
a = q - (p-1)(-1)
a = q + p - 1
Hence,
nth term = a + (n-1)d
= q + p -1 + (n-1)(-1)
= q + p -1 - n +1
= p + q - n