#include <iostream>
#include <sstream>
#include <string>
usingnamespace std;
int main() {
string s; // input as string.
int n; // input as int.
cout << "Enter a positive integer or 0: ";
cin >> s;
if (!(istringstream (s) >> n))
cout << "Error: You input string \"" << s << "\".\n"
<< "Input must have positive integer or 0 only.\n";
elseif (n < 0)
cout << "Error: You input negative integer " << n << ".\n"
<< "Input must have positive integer or 0 only.\n";
else {
longlong result = 1;
for (int i = 1; i <= n; i++)
result *= i;
cout << "Factorial(" << n << ") = " << result << endl;
}
}