Answers for "modulus program"

C#
1

modulus program

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;
}
Posted by: Guest on March-18-2022
1

modulus program

c = 1000000007
( a + b) % c = ( ( a % c ) + ( b % c ) ) % c
( a * b) % c = ( ( a % c ) * ( b % c ) ) % c
( a – b) % c = ( ( a % c ) – ( b % c ) ) % c
 
// below this is not ture statement
( a / b ) % c = ( ( a % c ) / ( b % c ) ) % c
Posted by: Guest on April-24-2022

C# Answers by Framework

Browse Popular Code Answers by Language