Query in broken calculator

Despite of using dynamic programming for calculating factorial of large no.s, the program is taking long time.Why is it so?
Here is the link of code

@ratulhans
The two conditions to use DP are

  1. Optimal Substructure
  2. Overlapping Subproblems

While factorial problem has Optimal Substructure , it does not have any overlapping problems and hence using DP is pointless here.
As for this problem , it asks you to calculate factorials of numbers as large as 500 is over 1100 digits large. No C++ predefined data type can hold such a large number and hence your code will not work. This problem isn’t actually much for computing factorials as that part is very easy. It is more of a problem for storing such large numbers and being able to perform the multiplication operation on it.
Try to think of a way around the issue of storing such large number to solve this problem.

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.