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