+ 2

Series

Can any one solve it? :- WAP to print the sum of this series:- 2+6+12+20........n

8th Mar 2018, 11:55 AM
Dipanjan Halder
Dipanjan Halder - avatar
2 Antworten
+ 16
s1= 2 + 6 + 12 + 20 4 6 8 2 2 0 //here general term forming is n(n+1) , by substracting s1 from s1 after shifting a term & then finding nth term //so u just need to do summation of nth term & formula comed ... 👉here is the formula formed [n.(n+1).(2n+1)] / 6 + n.(n+1)/2 //enjoy the 1-liner soln👍
8th Mar 2018, 12:36 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 12
//adding to my answer above , maths made it 1-liner , but U can try with programming also ... Use a loop //loop runs for number of terms U want to sum up start from t=4 & after each iteration of loop ... change value t to t+=2 , do sum+=t //sum=0 initially //hope mathematical & programming answer , both helped
8th Mar 2018, 12:59 PM
Gaurav Agrawal
Gaurav Agrawal - avatar