def linear_congruence(a, b, m):
 from sympy.polys.polytools import gcdex
 if ((a % m) == 0):
  if ((b % m) == 0):
   return list(range(m))
  else:
   return []
 (r, _, g) = gcdex(a, m)
 if ((b % g) != 0):
  return []
 return [((((r * b) // g) + ((t * m) // g)) % m) for t in range(g)]

def linear_congruence ( a , b , m ) : from sympy . polys . polytools import gcdex if ( ( a % m ) == 0 ) : if ( ( b % m ) == 0 ) : return list ( range ( m ) ) else : return [ ] ( r , _ , g ) = gcdex ( a , m ) if ( ( b % g ) != 0 ) : return [ ] return [ ( ( ( ( r * b ) // g ) + ( ( t * m ) // g ) ) % m ) for t in range ( g ) ]
returns the values of x satisfying a*x congruent b mod(m) here m is positive integer and a .