Take a look at the following question.
Determine all integers a for which \frac{a}{1011-a} is an even integer.
Hint: Let \frac{a}{1011-a} = 2d . Solve for a in terms of d.
(In the usual sense — if seeking for real roots, Diaphantus equations has infinitely many roots; but is has finite many roots if only the integer roots are sought.)
Suppose the expression \frac{a}{1011-a} gives an even integer 2d (d is an integer). This leads to
a = 2022 d – 2ad, which is (2d+1)a + (2) \cdot 1011d so a = (2) \frac{1011 d}{2d+1} = (2) \frac{(3)(337)d}{2d+1} -- -- (*)
Note a is integer and d is integer. By inspecting (*): the basic clue is that any prime factor of (2d+1) (in denominator) must be cancelled by the factors in the numerator — so that the quotient a is an integer. Note d and 2d +1 are co-prime; and numbers 3 and 337 are both prime numbers.
Therefore 2d +1 must take one of the following values: \pm1, \pm3, \pm 337, \pm1001 .
Here comes the last step to find the value of a. We leave it to the reader to complete.
By the way, can you see that in all solutions, a must be positive (i.e. a >0)? Yes, that is indeed true; otherwise if a <0, then the quotient will not be an integer — in fact, the absolute value of quotient will be between 0 and 1 (please figure out why).