You are viewing a single comment's thread. Return to all comments →
void extraLongFactorials(int n) { int factorial[1000]{0}, product{0}, digit{0}, carry{0}, length{1}; factorial[0]=1; for (int i = 2; i <= n; ++i) { for (int j = 0; j < length; ++j) { product = i * factorial[j] + carry; digit = product % 10; factorial[j] = digit; carry = product / 10; } while (carry) { digit = carry % 10; factorial[length] = digit; ++length; carry/=10; } } for (int k = length - 1; k >= 0; --k) { std::cout << factorial[k]; } }
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 →