c语言1+2+3+4+5
The series is: 1+(1+2) +(1+2+3) +(1+2+3+4) + ... +(1+2+3+...+n), we have to find out the sum up to N terms.
该序列是: 1+(1 + 2)+(1 + 2 + 3)+(1 + 2 + 3 + 4)+ ... +(1 + 2 + 3 + ... + n) ,我们有找出N个项之和。
Solution:
解:
We know the sum of natural numbers up to n = (n(n-1))/2
我们知道n等于(n(n-1))/ 2的自然数之和
If we simplify this we get, n(n+1)(2n+4)/12
如果我们简化一下,我们得到n(n + 1)(2n + 4)/ 12
If we put the number of terms in the above equation then we'll get the sum of the series up to that particular term.
如果我们将项数放在上述方程式中,那么我们将得到该特定项之前的序列之和。
Now, let's see Program it using the using c program,