0

If I have these equations
$a\equiv b \pmod c$

$d\equiv e \pmod c$
All known except $c$

and $\gcd(b−a,e−d)=1$

how do I find the unique solution for $c$?

and if the gcd!= 1 how do I find some possible solutions?

  • $\gcd(b-a,e-d)=1 \implies c=1$, $\gcd(b-a,e-d)\neq1 \implies c\neq1$. – barak manos May 11 '14 at 14:44
  • how do I solve for c? – user1510863 May 11 '14 at 14:44
  • 1
    Look, $b-a$ and $e-d$ are both divisible by $c$. So their greatest common divisor is $1$ if and only if $c=1$. – barak manos May 11 '14 at 14:46
  • I understand.. so the only unique solution for c = 1, how do I find other possible solutions if gcd!=1 – user1510863 May 11 '14 at 14:48
  • Well, the gcd is necessarily a multiple of $c$. If it's $1$ or any other prime number, then obviously $c$ is equal to that gcd. Otherwise, $c$ is equal to one of the (not necessarily prime) divisors of that gcd. In fact, the last sentence holds in the general case: $c$ is simply one of the divisors of the gcd. You can iterate for (int c=gcd; c>0; c--) until you find a $c$ for which $a \equiv b \pmod c$ and $d \equiv e \pmod c$. – barak manos May 11 '14 at 14:57
  • I dont understand what you mean by iterate.. any divisor for (b-a, and e-d) is a possible solution for C , there is no unique solution, correct – user1510863 May 11 '14 at 15:18
  • @user1510863 Generally $,c,$ satisfies the system of congruences iff $,c\mid\gcd(a-b,d-e),,$ see the equivalences in my answer. So the solution set is the set of (positive) divisors of the gcd. – Bill Dubuque May 11 '14 at 15:53
  • Related: http://math.stackexchange.com/questions/789739/mod-unknown-in-a-list-of-equations-with-all-knowns – Caleb Stanford May 11 '14 at 23:24

3 Answers3

1

$\begin{eqnarray}{\bf Hint}\qquad\quad a\equiv b\!\!\pmod{\! c}\\d\equiv e\!\!\pmod{\! c}\end{eqnarray}\iff $ $\begin{eqnarray} c\mid a-b\\c\mid d-e\end{eqnarray}\iff c\mid\gcd(a-b,d-e)$

This first equivalence is by definition of congruence, and the second is the universal gcd property.

Bill Dubuque
  • 282,220
0

In both cases, $c$ can be any of the (not necessarily prime) divisors of the $gcd$.

So you can simply pick $c=gcd(b-a,e-d)$.

barak manos
  • 43,599
0

$$b-a=mc\\d-e=nc\\gcd(b-a,d-e)=c*gcd(m,n)=1\\c=gcd(m,n)=1$$

kingW3
  • 13,734