Finding the value of x and the sum of terms in an AP