The formula to calculate the sum of n terms of AP is given as:
Sn= n/2[2a + (n – 1)d].
Where “a” is the first term, “d” is a common difference, and “n” is the number of terms.