Skip to content

Instantly share code, notes, and snippets.

@echo-akash
Created August 10, 2017 17:18
Show Gist options
  • Save echo-akash/8e96b3a3acb67e63d2ffd1e752d3011f to your computer and use it in GitHub Desktop.
Save echo-akash/8e96b3a3acb67e63d2ffd1e752d3011f to your computer and use it in GitHub Desktop.
Print the sum of the series: 1*2 + 2*3 + ....... + N*(N+1) = ?
#include<stdio.h>
int main()
{
int i,n,s;
s=0;
printf("enter the range:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("(%d*%d)",i,i+1);
if(i==n)
printf("=");
else
printf("+");
s=s+(i*(i+1));
}
printf("%d",s);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment