1 #include <iostream> 2 3 int main (void) { 4 int fact; 5 unsigned long res; 6 7 std::cin >> fact; 8 9 if(fact < 0) { 10 std::cerr << "Math ERROR" << std::endl; 11 return 1; 12 } 13 14 res = 1; 15 for (size_t i = 1; i <= (long unsigned int)fact; i++) { 16 res *= i; 17 } 18 19 std::cout << fact << "! = " << res << std::endl; 20 21 return 0; 22 }
