View Code of Problem 18

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(scanf("%d",&n) != EOF){
		int sum = 0;
		int k = 0;
		for(int i = 1; i <= n; i++){
			sum += k;
			if(i % 2 == 0){
				k++;
			}
		}
		cout<<sum<<endl;
	} 
}

Double click to view unformatted code.


Back to problem 18