title: Implement modInverse using Extended Euclid Algorithm in Java
body: <p>modInverse method of class BigInteger should not be used. I tried and used this method but it does not produce the correct result. Any help would be appreciated.</p>
  <pre><code>public static int[] extendedgcd(int a, int b) {
          if (b==0) {
              return new int[]{1, 0, a};
          } else {
              int output[] = extendedgcd(b, a%b);
              return new int[]{output[0], output[0]-((a/b)*output[1]), output[2]};
          }
      }
  </code></pre>