def order_mod(x, m):
 if (m <= 1):
  return 0
 assert (gcd(x, m) == 1)
 z = x
 result = 1
 while (z != 1):
  z = ((z * x) % m)
  result = (result + 1)
 return result

def order_mod ( x , m ) : if ( m <= 1 ) : return 0 assert ( gcd ( x , m ) == 1 ) z = x result = 1 while ( z != 1 ) : z = ( ( z * x ) % m ) result = ( result + 1 ) return result
return the order of x in the multiplicative group mod m .