Calculation of terms and common difference