Write a Python Program to find the Sum of Arithmetic Progression Series (A.P. Series) with a practical example.

## Python A.P. Series

Arithmetic Series is a sequence of terms in which the next item obtained by adding a common difference to the previous item. Or A.P. series is a series of numbers in which the difference of any two consecutive numbers is always the same. This difference called a common difference.

In Mathematical behind calculating Arithmetic Progression Series

Sum of A.P. Series : Sn = n/2(2a + (n – 1) d)

Tn term of A.P. Series: Tn = a + (n – 1) d

## Python Program to find Sum of Arithmetic Progression Series Example

This Python program allows the user to enter the first value, the total number of items in a series, and the common difference. Next, Python finds the sum of the Arithmetic Progression Series.

# Python Program to find Sum of Arithmetic Progression Series a = int(input("Please Enter First Number of an A.P Series: : ")) n = int(input("Please Enter the Total Numbers in this A.P Series: : ")) d = int(input("Please Enter the Common Difference : ")) total = (n * (2 * a + (n - 1) * d)) / 2 tn = a + (n - 1) * d print("\nThe Sum of Arithmetic Progression Series = " , total) print("The tn Term of Arithmetic Progression Series = " , tn)

**OUTPUT**

## Python Program to Calculate Sum of Arithmetic Progression Series Example 2

This Python Sum of the A.P program is the same as the above. Here, we used While Loop to display the A.P series, which is optional.

# Python Program to find Sum of Arithmetic Progression Series a = int(input("Please Enter First Number of an A.P Series: : ")) n = int(input("Please Enter the Total Numbers in this A.P Series: : ")) d = int(input("Please Enter the Common Difference : ")) total = (n * (2 * a + (n - 1) * d)) / 2 tn = a + (n - 1) * d i = a print("\nThe tn Term of Arithmetic Progression Series = " , tn) print("The Sum of Arithmetic Progression Series : ") while(i <= tn): if(i != tn): print("%d + " %i, end = " ") else: print("%d = %d" %(i, total)) i = i + d

**OUTPUT**

## Python Program to Calculate Sum of Arithmetic Progression Series without Math Formula

In this Python program, we are not using any Mathematical formula.

# Python Program to find Sum of Arithmetic Progression Series a = int(input("Please Enter First Number of an A.P Series: : ")) n = int(input("Please Enter the Total Numbers in this A.P Series: : ")) d = int(input("Please Enter the Common Difference : ")) total = 0 value = a print("Arithmetic Progression Series : ", end = " ") for i in range(n): print("%d + " %value, end = " ") total = total + value value = value + d print("\nThe Sum of Arithmetic Progression Series upto %d = %d " %(n, total))

**OUTPUT**

## Python Program to Calculate Sum of Arithmetic Progression Series using Functions

This Python Sum of Arithmetic Progression is the same as the first example. However, we separated the logic using Functions.

# Python Program to find Sum of Arithmetic Progression Series def sumofAP(a, n, d): total = (n * (2 * a + (n - 1) * d)) / 2 return total a = int(input("Please Enter First Number of an A.P Series: : ")) n = int(input("Please Enter the Total Numbers in this A.P Series: : ")) d = int(input("Please Enter the Common Difference : ")) total = sumofAP(a, n, d) print("\nThe Sum of Arithmetic Progression Series = " , total)

**OUTPUT**