

Let first term of AP = a
Last term of AP = l
common difference = d
Now sum of AP = 400
=> (n/2)*(a + l) = 400
=> (n/2)*(5 + 45) = 400 (Given a = 5, l = 45)
=> (50*n)/2 = 400
=> 50*n = 400*2
=> 50*n = 800
=> n = 800/50
=> n = 16
Again,
l =a + (n-1)*d
=>45 = 5 + (16-1)*d
=>45-5 = 15*d
=>40 = 15*d
=>d = 40/15
=> d = 8/3 (when 40 and 15 is divided by 5)
So number of terms in AP is 16 and common difference is 8/3
