You are given a non-negative integer n.
Your task is to compute n! (n factorial) modulo 10^9 + 7 (1000000007).
Remember that:
n! (n factorial) is the product of all positive integers from 1 to n.0! = 1.10^9 + 7 is a large prime number commonly used as a modulus to prevent integer overflow.Return n! % (10^9 + 7).
5
120
5! = 120. Since 120 < 10^9 + 7, the result is simply 120.
13
227020758
13! = 6,227,020,800. Since this exceeds 10^9 + 7, we return 6,227,020,800 % 1,000,000,007 = 227,020,758.
0
1
0! = 1 by convention. Since 1 < 10^9 + 7, the result is 1.
5
120