View Code of Problem 18

#include<iostream>

using namespace std;

int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		int sum = 0;
        for(int i = 1; i < n / 2; i++)
            sum += i;
        for(int i = 1; i < n - n / 2; i++)
            sum += i;
        cout << sum << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 18