You are viewing a single comment's thread. Return to all comments →
void multiply(int x, vector& result, int& result_size) { int carry = 0;
for (int i = 0; i < result_size; i++) { int prod = result[i] * x + carry; result[i] = prod % 10; carry = prod / 10; } while (carry) { result[result_size] = carry % 10; carry = carry / 10; result_size++; }
} void extraLongFactorials(int n) { vector result(1000, 0); result[0] = 1; int result_size = 1;
for (int x = 2; x <= n; x++) { multiply(x, result, result_size); } for (int i = result_size - 1; i >= 0; i--) { cout << result[i]; } cout << endl;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Extra Long Factorials
You are viewing a single comment's thread. Return to all comments →
void multiply(int x, vector& result, int& result_size) { int carry = 0;
} void extraLongFactorials(int n) { vector result(1000, 0); result[0] = 1; int result_size = 1;
}