Let a be the first term and d be the common difference.
We know that, nth term = an = a + (n − 1)d
According to the question,
a5 = 31
⇒ a + (5 − 1)d = 31
⇒ a + 4d = 31
⇒ a = 31 − 4d .... (1)
Also, a25 = 140 + a5
⇒ a + (25 − 1)d = 140 + 31
⇒ a + 24d = 171 .... (2)
On substituting the values of (1) in (2), we get
31 − 4d + 24d = 171
⇒ 20d = 171 − 31
⇒ 20d = 140
⇒ d = 7
⇒ a = 31 − 4 × 7 [From (1)]
⇒ a = 3
Thus, the A.P. is 3, 10, 17, 24, .... .