I used an array to store previous computed factorial so that I don’t have to compute again. Still getting failed. What am I missing?
Approach to take
This is not a simple factorial question. The range of long long int in C++ is 10^18. And therefore we can store only factorial of numbers below 20.
In this question you are supposed to find the factorial of 500 . Which cannot be stored in any predefined data type . So for this we need to compute factorial using primary mathematics multiplication and store each multiplication in an array.
you mean we need to store digits in an array? rather than storing one result as one element, we’ll be storing digitwise. something like that?
Yeah absolutely you should keep digits in the array for each factorial.
Have a look at this for reference
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.