title: Efficient algorithm for finding a common divisor closest to some value?
body: <p>I have two numbers, <code>x1</code> and <code>x2</code>. For a number <code>y</code>, I want to calculate the common divisor of <code>x1</code> and <code>x2</code> as close as possible to <code>y</code>.</p>
  
  <p>Is there an efficient algorithm for this?</p>
  
  <hr>
  
  <p><em>I believe it's time to rephrase my problem and be more clear</em>. This is not about integers...
  So, say we have two numbers <code>x1</code> and <code>x2</code>. Say, the user inputs a number <code>y</code>. What I want to find, is a number <code>y'</code> close to <code>y</code> so that <code>x1 % y'</code> and <code>x2 % y'</code> are very small (smaller than <code>0.02</code>, for example, but lets call this number <code>LIMIT</code>). In other words, I don't need an optimal algorithm, but a good approximation.</p>
  
  <p>I thank you all for your time and effort, that's really kind!</p>