#include <iostream>
#include <string>
#include <algorithm>
using std::string, std::to_string, std::reverse;
namespace multiplication {
string multiply(string A, string B) {
reverse(A.begin(), A.end());
reverse(B.begin(), B.end());
size_t m = A.size(), n = B.size();
string C(m + n, '0');
for (int i, carry = i = 0; i < n; ++i, carry = 0) {
for (int j = 0, num; j < m; ++j) {
num = (C[i + j] - '0') + carry + ((A[j] - '0') * (B[i] - '0'));
C[i + j] = (num % 10) + '0';
carry = num / 10;
}
C[i + m] += carry;
}
reverse(C.begin(), C.end());
return C;
}
string multiply(int a, int b) {
string
A = to_string(a),
B = to_string(b);
return multiply(A, B);
}
string multiply(int a, string B) {
string A = to_string(a);
return multiply(A, B);
}
}
using multiplication::multiply;
namespace factorial {
string f(int num) {
string res = "1";
for (int n = num; n > 0; --n) {
res = multiply(n, res);
}
string ans;
bool flag = false;
for (const char& c : res) {
if (c - '0') flag = true;
if (flag) ans.push_back(c);
}
return ans;
}
}
using factorial::f;
using std::cout, std::endl;
int main(void) {
int num = 54;
cout << f(num) << endl;
return 0;
}