View Code of Problem 30

#include<iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <cmath>
using namespace std;
#pragma warning(disable:4996)


int main() {
	int n;
	
	while (scanf("%d", &n) != EOF) {
		int x = 0;
		for (int i = 1; i <= n; i++) {
			x += i;
		}
		printf("%d\n", x);
	}
	return 0;
}	

Double click to view unformatted code.


Back to problem 30