We know that the sum of N numbers will be equal to N * (average of all the terms). Sum of 50 terms in the arithmetic sequence is: 2600Īlternatively, we can also derive a mathematical expression for calculating the sum of N terms of the arithmetic sequence. Print("Sum of 50 terms in the arithmetic sequence is:", sumOfTerms) IthTerm = firstTerm + (i - 1) * commonDifference After that, we will add the each term to calculate the sum of N terms as follows. In the for loop, we will first find each term using the formulae discussed above. To find the sum of N terms in an arithmetic expression, we can simply add each term using a for loop. NthTerm = firstTerm + (N - 1) * commonDifferenceġ00th term in the arithmetic sequence is: 201 Sum Of N Terms In An Arithmetic Sequence In Python Output: Common Difference in the arithmetic sequence is: 2įirst term in the arithmetic sequence is: 3ġ00th term in the arithmetic sequence is: 201Īlternatively, we can directly calculate the Nth term using the formulae as follows. Print("100th term in the arithmetic sequence is:", nthTerm) Print("First term in the arithmetic sequence is:", firstTerm) Print("Common Difference in the arithmetic sequence is:", commonDifference) The Nth term will be written as A 1+(N-1)D To find the Nth term of an arithmetic sequence in python, we can simply add the common difference (N-1) times to the first terms A 1 using a for loop as follows. If we are given the first term A 1 and the common difference D, we can write the second term as A 1+D, the third term as A 1+2D, the fourth term as A 1+3D, and so on.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |