#include<iostream>
#include <iomanip>
using namespace std;

//double datatype is used here so that more large numbers can be dealt with

double factorial(double x) {
	double r;
	if (x == 0 || x == 1) {
		r = 1;
	} else {
		r = x * factorial(x-1);
	}
	return r;
}

int main() {
	cout << "n! \n";
	cout << "To exit => n<0 \n\n";
	while (true) {
		int n;
		cout << "n = ";
		cin >> n;
		if (n<0) {
			cout << "The program is terminated. Bye!";
			break;
		} else {
			cout << n << "! = " << fixed << setprecision(0) << factorial(n) << endl << endl;
		}	
	}
	return 0;
}
