title: Solve mod equation in JS
body: <p>I need to find an <code>x</code> value that satisfied:</p>
  
  <pre><code>x * a % m == b
  x * c % n == d
  </code></pre>
  
  <p>Is there a smarter way to find the solution without iterating all the possibilites ?</p>
  
  <pre><code>function solve()
  {
      for (x=0;x&lt;n*m-1;x++)
      {
          if((x * a % m == b) &amp;&amp; (x * c % n == d))
               return true;
      }
      return false;
  }
  </code></pre>