Showing:
Handle Score
@Ibrahim Nash 6420
@mb1973 5594
@Quandray 5231
@akhayrutdinov 5111
@saiujwal13083 4510
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3412
Large Factorial
Medium Accuracy: 73.47% Submissions: 7527 Points: 4

You are given an array A of integers of length N. You need to calculate factorial of each number. The answer can be very large, so print it modulo 10+ 7.

Example 1:

Input:
N = 5
A[] = {0, 1, 2, 3, 4}
Output:
1 1 2 6 24
Explanation:
Factorial of 0 is 1,
factorial of 1 is 1, factorial of 2 is 2,
factorial of 3 is 6 and so on.



Example 2:

Input:
N = 3
A[] = {5, 6, 3}
Output:
120 720 6
Explanation:
Factorial of 5 is 120,
factorial of 6 is 720,
factorial of 3 is 6.

Complete the function factorial() which takes listand single integer n, as input parameters and returns a list of factorials of the numbers in the list a.

Expected Time Complexity: O(max(A) + N)
Expected Auxiliary Space: O(max(A))

Constraints:
1 <= N <= 105
0 <= A[i] <= 105