You are on page 1of 9

Linear modular equation

• Definition: a mod n means the remainder when a is divided by n

• Definition. (modulo equivalence)

• We will say that a and b are equivalent modulo n.


Linear Congruences
Algorithm
Modular linear equation(a,b,n)
1. (d,x1 ,y1 ) 🡸 Extended Euclid(a,n)
2. If d/b
3. then x0 🡸 x1 (b/d) mod n
4. For i🡸0 to d-1
5. do print x1 🡸 (x0 + i(n/d))mod n
6. Else
7. print “ no solutions”.
Working rule
1. Compute d=gcd(a,n) as well as two values x1 and y1 such that

d=ax1 +ny1

Demonstrating that x1 is a solution to the equation ax1≡ d(mod n).

2. If d does not divide b, then the equation has no solution.


Extended Euclidian algorithm
Example: 35x≡ 10(mod 50)
a=35, b=10, n=50

d=gcd(a,n)
=gcd(35,50)
d=5 🡸 There are 5 solutions.
• d=ax1 +ny1
• 5=35x1 +50y1
• Put x1 =3 and y1 =-2
• 5=35(3)+50(-2)
• 5=105-100
• 5=5
• x0= x1 (b/d)mod n
• X0=3(10/5)mod 50
• =6 mod 50
• X0=6

For i🡸0 to d-1


X1=x0+i(n/d))mod n

You might also like