#include <iostream>
#include <stdexcept>
#include <string>
using std::cout;
using std::endl;
using std::string;
class negative_argument : public std::invalid_argument
{
public:
explicit negative_argument(const string& what_arg) : std::invalid_argument(what_arg) {}
};
int fak(int n)
{
if (n < 0) throw negative_argument("von negativen Zahlen kann man die Fakultaet nicht berechnen");
int result = 1;
for (int i = 2; i <= n; ++i)
{
result *= i;
}
return result;
}
int main()
{
for (int i = -1; i <= 10; ++i)
{
try
{
cout << fak(i) << ", ";
}
catch (std::exception& e)
{
cout << e.what() << ", ";
}
}
cout << endl;
return 0;
}