I want to solve for positive integral values of $x$ and $y$: $$1216562x=87654321y+a$$ Here $a$ is a positive integer. For example if $a=40642509$ then one solution is : $x=37716$ and $y=523$
How do I proceed? I shall be grateful if anyone can help me.
Hint : Use the extended euclidean algorithm : Calculating the steps leading to the gcd backwards allows to find a linear combination $ax+by=c$, where c is the gcd, here $1$.
Example : $a=18 , b = 5$
$$18 = 5*3+3$$ $$5 = 3*1 + 2$$ $$3 = 2*1 + 1 $$
So, we have $$1=3-2 = 3-(5-3) = 2*3-5 = 2*(18-5*3)-5 = 2*18-7*5$$