Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
233 B
0
Indexable
Never
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int sum = 0;

	if (n > 0 && n != 0)
	{
		for (int i = 1; i <= n; i++)
			sum += i;
	}
	else
	{
		for (int i = 1; i >= n; i--)
			sum += i;
	}
	cout << sum;
}