Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java Modulo 10^9+7 (1000000007)

static long factorial(int n)
{
    long M = 1000000007;
 
    long f = 1;
    for (int i = 1; i <= n; i++)
        f = (f*i) % M;  // Now f never can
                        // exceed 10^9+7
    return f;
}
 
// This code is contributed by Dharanendra L V.
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #java #Modulo
ADD COMMENT
Topic
Name
9+3 =