119. C Program to Compute the 1+3+6+10+ …………+n series.
How does this program work?
- This program is used to compute the sum of series for the given order.
- Here we are going to find the series for 1+3+6+10+ …………………+n upto nth term.
- where The nth term is the user input.
- Computing the given series is easy by Using the simple for loop condition.
Here is the code
#include <stdio.h>
int main(void)
{
int n,sum = 0;
printf("Enter series of number\n");
scanf("%d",&n);
for (int i=1; i<= n; i++)
{
sum += i*(i+1)/2;
}
printf("for series of 1+3+6+10... n numbers n=%d sum of series= %d",n,sum);
return 0;
}