Problem:Objective: To find the Factorial of Numbers whose factorial is of the order 10^7.Input:- First line takes t number of test case
- the next t lines takes the number whose factorial is to be found.
Output: The next t lines after input gives the ouput.
Code
Explaination:
We are storing the factorial in parts in array indices. Instead of finding the factorial of given number we are finding the factorials of all numbers upto 100001 in their respective array indices and just print the desired facts.
By taking mod with our self defined value of 10^7 we are in a way compressing the number at each level so that are data types can hold that value.
a[i] = ((i%mod)*(a[i-1]%mod))%mod;
The above line of code is very important to understand the code.This is the line in which through which we are compressing the number to our data type limits (long long)