View Code of Problem 18

#include<stdio.h>
int main()
{
	int n;int k,j; 
	while(scanf("%d",&n)!=EOF)
	{
		j=1;k=0;
		if(n<=2)
		printf("0\n");
		else
		{
			while(n>2)
			{
				j+=k;
				k++;
				n--;
			}
			printf("%d\n",j);
		}
	}
	return 0; 
}

Double click to view unformatted code.


Back to problem 18