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)

## 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

Python Sum of Arithmetic Progression output

```
Please Enter First Number of an A.P Series: : 2
Please Enter the Total Numbers in this A.P Series: : 6
Please Enter the Common Difference : 4
The tn Term of Arithmetic Progression Series = 22
The Sum of Arithmetic Progression Series :
2 + 6 + 10 + 14 + 18 + 22 = 72
```

## 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))

Python Sum of Arithmetic Progression output

```
Please Enter First Number of an A.P Series: : 1
Please Enter the Total Numbers in this A.P Series: : 4
Please Enter the Common Difference : 5
Arithmetic Progression Series : 1 + 6 + 11 + 16 +
The Sum of Arithmetic Progression Series upto 4 = 34
```

## 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)

Python Arithmetic Progression sum output

```
Please Enter First Number of an A.P Series: : 2
Please Enter the Total Numbers in this A.P Series: : 5
Please Enter the Common Difference : 10
The Sum of Arithmetic Progression Series = 110.0
```