src/com/michaelho/RandomizedAlgorithms/RA1.java
/**
         * Multiplicative inverse is another name for reciprocal, which is try to find the number to multiply
         * in order to get 1. For example, if x = 3, N = 11, the result will be 4 since 3*4%11 = 1.
         * Given two integers x and N, find modular multiplicative inverse of x under modulo N.
         * Reference: https://www.geeksforgeeks.org/modular-multiplicative-inverse-1-n/
         *
         * @param x The integer as base number.
         * @param N the modulo N.
         * @return The multiplicative inverse of the x mod N, which is indicated as x^-1 mod N.
         * */
Multiplicative inverse is another name for reciprocal, which is try to find the number to multiply
in order to get 1. For example, if x = 3, N = 11, the result will be 4 since 3*4%11 = 1.
Given two integers x and N, find modular multiplicative inverse of x under modulo N.

@param x The integer as base number.
@param N the modulo N.
@return The multiplicative inverse of the x mod N, which is indicated as x^-1 mod N.
Multiplicative inverse is another name for reciprocal which is try to find the number to multiply in order to get 1 . For example if x = 3 N = 11 the result will be 4 since 3 * 4%11 = 1 . Given two integers x and N find modular multiplicative inverse of x under modulo N . @param x The integer as base number . @param N the modulo N . @return The multiplicative inverse of the x mod N which is indicated as x^ - 1 mod N .
int multiplicativeInverse(int x, int N) {
            x = x % N;
            for (int i = 1; i < N; i++) {
                if ((x * i) % N == 1)
                    return i;
            }
            return -1;
        }
int multiplicativeInverse ( int x , int N ) { x = x % N ; for ( int i = 1 ; i < N ; i ++ ) { if ( ( x * i ) % N == 1 ) return i ; } return - 1 ; }
Multiplicative inverse is another name for reciprocal, which is try to find the number to multiply
 in order to get 1.
Multiplicative inverse is another name for reciprocal which is try to find the number to multiply in order to get 1 .
// If the multiplicative inverse does not exist.