Write a program to the sum of AP | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Write a program to the sum of AP

series:- 1+2+3+4+5+6+7+8+9+10

31st Oct 2017, 6:23 AM
Ishant Dwivedi
Ishant Dwivedi - avatar
2 Answers
+ 5
@Gordie Sorry, I assumed that if he knew what an AP was, he must be familiar with the usual symbols, a, n and d.
1st Nov 2017, 6:30 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 3
Or for a general AP: S = (n/2)*((2*a)+((n-1)*d)); Where the symbols stand for the usual meanings: a = First Term, d = Difference of adjacent terms, n = Number of Terms. And if you don't have the 'd', but instead the last term 'l' : S = (n/2)*(a+l);
1st Nov 2017, 2:39 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar