Sum of an Arithmetic Series
A sequence of numbers is called an Arithmetic series when the difference between any two consecutive numbers in the series is always the same. For example, 1,4,7,10,13,16 .... is an arithmetic sequence with the starting number as 1 and the difference between. each term is 3.
A Flowchart to Calculate the Sum of an Arithmetic Series
Python Source Code to Calculate the Sum of an Arithmetic Series
Output For the Sequence 1+2+3+4...+99+100
Output For the Sequence 2+7+12+17+22
Mathematical formula
Using the above method to find the sum of an arithmetic series can be a time consuming task, if the number of terms is large.
For example, given the arithmetic sequence whose first few terms are :
2,5,8,11,14,17,.......
If we need to calculate the sum of its first 100 terms, we can do that by adding one term to the next up to the 100th terms. But it can take some time. Instead we can derive a formula to solve it.
Let us represent the arithmetic series as below
a1+ a2 + a3 + a4 ........... + an-1 + an
where
a1 is the first number in the series.
n is the number of terms in the series.
d is the difference between two terms.
Since the difference between two consecutive terms is always the same, we can also write the sequence as below
a1+ (a1 +d) + (a1 + 2d) + ............. +(a1 + (n-2)d ) + (a1 + (n-1)d )
the last term in the series will be a1 + (n-1) * d . We use (n-1) because d is not used in the first term.
The mathematical formula to calculate the sum of arithmetic series will be
Sum = ( First Number + Last Number ) * numOfTerms/2
therefore,
Sum = ( 2a1 + (n-1) * d ) * n/2
Python Source Code to Calculate the Sum of Arithmetic Series Using Mathematical Formula
Output For the Sequence 1+2+3+4...+99+100
Comments
Post a Comment