Determining the sum of terms in an A.P.