0

I have the following equation. I need to find all integers.

$241 \times a + 114 \times b = 1$

As per Wolframalpha the solution would be:

$a=114n+79, b=-241n-167,n \in \mathbb{Z}$

But how do you get to that solution? I tried to solve for $a$ and $b$

$a=\frac{1-114b}{241}$

$b=\frac{1-241a}{114}$

But that does not help me.

Chris
  • 521

1 Answers1

2

We wish to find $a$ and $b$ such that $241\times a + 114\times b = GCD(241,114)$. Using Extended Euclidean algorithm, we first find the GCD by recursively applying $GCD(a,b) = GCD(b, a\bmod b)$.

We can form the following equations to obtain $GCD(241, 114)$:

$$\begin{align*} 241 =& 114\times 2 + \color{red}{13}& 241 \bmod114 =& \color{red}{13}\\ 114 =& \color{red}{13}\times 8 + \color{orange}{10}& 114 \bmod \color{red}{13} =& \color{orange}{10}\\ \color{red}{13} =& \color{orange}{10}\times1 + \color{green}{3}& \color{red}{13} \bmod \color{orange}{10} =& \color{green}{3}\\ \color{orange}{10} =& \color{green}{3}\times3 + \color{blue}{1}& \color{orange}{10}\bmod \color{green}{3} =&\color{blue}{1}\\ \end{align*}$$

The above is the first step, the "original" Euclidean algorithm. $GCD(241,114)$ is now obtained to be $1$. The extended part is as follows to find $a$ and $b$. Starting from the last equation above:

$$\begin{align*} \color{blue}{1} =& \color{orange}{10} - \color{green}{3}\times3\\ =& \color{orange}{10} - (\color{red}{13} - \color{orange}{10}\times1)\times3\\ =& \color{red}{13}\times(-3) + \color{orange}{10} \times 4\\ =& \color{red}{13}\times(-3) + (114 - \color{red}{13}\times 8) \times 4\\ =& 114\times4 + \color{red}{13}\times(-35)\\ =& 114\times4 + (241-114\times2)\times(-35)\\ \color{blue}{1}=& 241\times(-35) + 114\times74 &(1) \end{align*}$$

The above involves alternate substituting remainders and grouping remainder terms. That gave $a=-35$ and $b=74$ as one solution.

Since $GCD(241, 114) = 1$, we know $LCM(241,114) = 241\times114$, and so

$$\begin{align*} 241 \times \frac{LCM(241,114)}{241} =& 114 \times\frac{LCM(241,114)}{114}\\ 241 \times 114 =& 114 \times241\\ 0 =& 241 \times 114 + 114 \times(-241) &(2) \end{align*}$$

The reason for me to write this trivial equation out is that, you can add $k$ times of equation $(2)$ to $(1)$, and the sum would still be $1$. Therefore, in general $$a = 114k - 35,\ b=-241k + 74$$

Your solution from WolframAlpha is off by one solution: $n=k-1$

peterwhy
  • 22,256
  • That is pretty cool. I googled a little bit and found also that $GCD(a,b)=ax+by$ where $x_i=y_{i+1}$ and $y_i=x_{i+1}-q_i \times y_{i+1}$ with this I got the same result that $1=241 \times -35 + 114 \times 74$ – Chris Nov 27 '13 at 09:31