2,6,12,20,30,...,n
Solution using C language:
#include <stdio.h>
int main() {
int n;
printf("Enter the range\n");
scanf("%d",&n);
int sum = ((n*(n+1))/2)+((n*(n+1)*(2*n+1))/6);
printf("the sum of series till %d is %d", n,sum);
return 0;
}
Output:
Enter the range
3
the sum of series till 3 is 20
No comments:
Post a Comment