//Xinnuo Wang                   CS1A                   chapter 5 , P.294, #1
//
/*******************************************************************************
*
* Sum of Numbers
*-------------------------------------------------------------------------------
* This program accepts an intenger nember, sum all the integers from 1 to
* it, and valid the input.
*
* computation is based on the formula:
* sum = numb 1+ numb 2+...+num n
*-------------------------------------------------------------------------------
* INPUT
*    numb n      : the asked and the max number
*  
* OUTPUT
*    total      : the sum of numbers from 1 to n.
*
*******************************************************************************/
#include <iostream>
using namespace std;

int main() 
{
	int numbN;
	int numb=0;
	int total=0;
	cout<< "Enter the max number to sum"<< endl;
	cin >> numbN;
	while (numbN<0)
	{
		cout<<"Invalid Input"<< endl;
		return 0;
	}
	
	while(numb<=numbN)
	{
		total+=numb;
		numb++;
	}
	cout<< "The total is: "<< total<< endl;
	return 0;
}