The first and the last terms of an AP are 5 and 45 respectively. If the sum of all its terms is 40, find the common difference and the number of terms.
Given that, a = 5,
l = 45 and Sn = 400
Sn=n2[a+l]
400=n2(5+45)
400=n2(50)
n=16
l=a+(n−1)d
45=5+(16−1)d
40=15d
d=4015=83