#include <iostream>
#include <stdexcept>
#include <limits>
using namespace std;

int main(){
	cout << "Even Natural Numbers Less than n \n";
	cout << "To exit: n < 0 \n\n";
	while (true) {
		try{
			int n;
			cout << "n = ";
			cin >> n;
			if (cin.fail()){
				throw invalid_argument("Error! You have to enter a natural number!");
			}
			if (n>0){
				for (int i=2; i<n; i+=2) {
					cout << i << endl;
				}				
			} else {
				cout << "The program is terminated!";
				break;
			}
			cout << endl;
		} catch (const invalid_argument& e){
			cin.clear(); 
            cin.ignore(numeric_limits<streamsize>::max(), '\n'); 
			cout << e.what() << endl << endl;
		}
	}
	return 0;
}
