Number of terms and sum in an AP