def is_nthpow_residue(a, n, m):
 (a, n, m) = [as_int(i) for i in (a, n, m)]
 if (m <= 0):
  raise ValueError('m must be > 0')
 if (n < 0):
  raise ValueError('n must be >= 0')
 if (a < 0):
  raise ValueError('a must be >= 0')
 if (n == 0):
  if (m == 1):
   return False
  return (a == 1)
 if (n == 1):
  return True
 if (n == 2):
  return is_quad_residue(a, m)
 return _is_nthpow_residue_bign(a, n, m)

def is_nthpow_residue ( a , n , m ) : ( a , n , m ) = [ as_int ( i ) for i in ( a , n , m ) ] if ( m <= 0 ) : raise ValueError ( 'm must be > 0' ) if ( n < 0 ) : raise ValueError ( 'n must be >= 0' ) if ( a < 0 ) : raise ValueError ( 'a must be >= 0' ) if ( n == 0 ) : if ( m == 1 ) : return False return ( a == 1 ) if ( n == 1 ) : return True if ( n == 2 ) : return is_quad_residue ( a , m ) return _is_nthpow_residue_bign ( a , n , m )
returns true if x**n == a has solutions .