def inverse_mod(num_a, num_b):
  """Returns inverse of a mod b, zero if none

  Uses Extended Euclidean Algorithm

  :param num_a:
      Long value
  :param num_b:
      Long value
  :returns:
      Inverse of a mod b, zero if none.
  """
  num_c, num_d = num_a, num_b
  num_uc, num_ud = 1, 0
  while num_c:
    quotient = num_d // num_c
    num_c, num_d = num_d - (quotient * num_c), num_c
    num_uc, num_ud = num_ud - (quotient * num_uc), num_uc
  if num_d == 1:
    return num_ud % num_b
  return 0