Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

c++ Modulo 10^9+7 (1000000007)

unsigned long long factorial(int n)
{
    const unsigned int M = 1000000007;
 
    unsigned long long f = 1;
    for (int i = 1; i <= n; i++)
        f = (f*i) % M;  // Now f never can
                        // exceed 10^9+7
    return f;
}
 
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Modulo
ADD COMMENT
Topic
Name
6+9 =