In this Python program, we will learn how to calculate the sum of the **Arithmetic Progression(A.P.)** series. In this program, we calculate the sum of A.P. series with or without using mathematics formula.

In mathematics, an **arithmetic progression** (AP) or **arithmetic** sequence is a sequence of numbers such that the difference between the consecutive terms is constant. ... The sum of a finite **arithmetic progression** is called an **arithmetic series**. The behavior of the **arithmetic progression** depends on the common difference d. For instance, sequence 5, 9, 13, 17, 21, . . . is an arithmetic progression with a common difference of 4.

Sum of Nth terms of A.P. Series = (n(2a + (n-1)d))/2

Where a = the first number of the A.P. series

n = total number in the A.P. series

d = common difference between numbers in the A.P. series.

In this program, we calculate the sum of the A.P. series in two ways. The first way is by using the mathematics formula and the second way is without using a mathematics formula.

Here is the source code of the program to calculate the sum of the Arithmetic Progression(A.P.) series.

```
# Python Program to Calculate the Sum of Arithmetic Progression
# Series Using Math Formula
# Take the Input from the User
first_Num = int(input("Enter First Number of an A.P Series: "))
Total_num = int(input("Enter the Total Numbers in this A.P Series: "))
diff = int(input("Enter the Common Difference: "))
# Calculation
total = (Total_num * (2 * first_Num + (Total_num - 1) * diff)) / 2
tn = first_Num + (Total_num - 1) * diff
# Print the Output
print("\nThe Sum of Arithmetic Progression Series = " , total)
print("The tn Term of Arithmetic Progression Series = " , tn)
```

Enter First Number of an A.P Series: 5

Enter the Total Numbers in this A.P Series: 6

Enter the Common Difference: 15

The Sum of Arithmetic Progression Series = 255.0

The tn Term of Arithmetic Progression Series = 80

```
# Take the Input From the User
first_Num = int(input("Enter First Number of an A.P Series: "))
Total_num = int(input("Enter the Total Numbers in this A.P Series: "))
diff = int(input("Enter the Common Difference: "))
# Calculation
total = (Total_num * (2 * first_Num + (Total_num - 1) * diff)) / 2
tn = first_Num + (Total_num - 1) * diff
i = first_Num
# Print the Output
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 + diff
```

Enter First Number of an A.P Series: 5

Enter the Total Numbers in this A.P Series: 6

Enter the Common Difference: 15

The tn Term of Arithmetic Progression Series = 80

The Sum of Arithmetic Progression Series:

5 + 20 + 35 + 50 + 65 + 80 = 255

In the program 1 and 2 **tn **term is the last number of A.P. Series

```
# Python Program to Calculate the Sum of Arithmetic Progression Series
# Without using Mathematics Formula
# Take the Input From the User
first_Num = int(input("Enter First Number of an A.P Series: "))
Total_num = int(input("Enter the Total Numbers in this A.P Series: "))
diff = int(input("Enter the Common Difference: "))
APseries=""
total = 0
value = first_Num
# Calculation
for i in range(Total_num):
APseries= APseries + " + " + str(value)
total = total + value
value = value + diff
# Print the Output
print("\nArithmetic Progression Series: ", APseries.lstrip(' + '))
print("\nThe Sum of Arithmetic Progression Series upto %d = %d " %(Total_num, total))
```

Enter First Number of an A.P Series: 5

Enter the Total Numbers in this A.P Series: 6

Enter the Common Difference: 15

Arithmetic Progression Series: 5 + 20 + 35 + 50 + 65 + 80

The Sum of Arithmetic Progression Series upto 6 = 255

## Comments