Solving Linear Diophantine Equations and
Solving Linear Diophantine Equations and
2012-06-01
Author: Deniz Yesilyurt
Subject: Mathematics
Level: Bachelor
Course code: 2MA11E
Abstract
This report represents GCD, euclidean algorithm, linear diophan-
tine equation and linear congruential equation. It investigates the
methods for solving linear diophantine equations and linear congru-
ential equations in several variables. There are many examples which
illustrate the methods for solving equations.
2
Contents
1 Introduction 4
3 Linear Congruence 27
3.1 Introduction to Congruence . . . . . . . . . . . . . . . . . . . 27
3.2 Linear Congruences . . . . . . . . . . . . . . . . . . . . . . . . 28
4 Conclusion 35
3
1 Introduction
Linear diophantine equations got their name from Diophantus. Diophantus
of Alexandria was a mathematician who lived around the 3rd century. Dio-
phantus wrote a treatise and he called ’Arithmetica’ which is the earliest
known book on algebra.
A Diophantine equation is an algebraic equation for which rational or
integral solutions are sought. An algebraic equation is one that involves only
polynomial expressions in one or more variables. What makes the equation
’Diophantine’ is that the coefficients of the polynomials should be ratio-
nal numbers(or often integers)and also solutions must be only rational(or
integer).
Brahmagupta(598-670)was the first mathematician who gave general so-
lution of the linear diophantine equation (ax + by = c). Diophantus didn’t
use complicated algebraic notation, but Brahmagupta used the complicated
notations for solving equation.
Two well known results from beginning number theory are examples of
diophantine equations which predate Diophantus. Both of these problems
were known by the Babylonians. These are;
And also we can mention linear congruences. First, Carl Freidrich Gauss
considered the congruences and he developed congruences. Gauss noticed;
when he try to solve the linear diophantine equations(ax + by = c); if m|(a −
b), then we write a ≡ b (mod m), and a is congruent to b modulo m.
Except Gauss, many scientist seek the linear congruences and solutions
of them. Some of them; J.konig [1],Th.Schnemann [2] and M.Fekete [3].
Congruences are used in our daily life, today is monday or the time
is 15:00. The periodic nature of dates and time can be described using
congruences.
The purpose of this study is derive algorithms for finding all the solutions
of linear diophantine equation of the form
a1 x1 + a2 x2 + · · · + an xn = b.
and also we will derive algorithm for solving the linear congruential equa-
tion;
a1 x1 + a2 x2 + · · · + an xn ≡ b (mod m).
In this project, we have two main sections. First section is about linear
diophantine equation. There are required definitions and theorems for ex-
plaining linear diophantine equation. These are GCD, euclidean algorithm,
4
extended euclidean algorithm and linear diophantine equation. There are
also some examples for understand the theorems and definitions better. In
the last part of first section, there are two applications which are related to
linear diophantine equation. We will see that linear diophantine equation in
more than two variables can be solved by induction method.
Second section is about linear congruential equation. It contains in-
troduction to congruences, basic congruences theorems, linear congruences
theorems and also definitions for solving linear congruential equation in sev-
eral variables. We will search for the number of incongruent solutions of
linear congruential equation in various variables. We will find the number
of solutions to linear congruential equation in one variable and by generaliza-
tion, we will get the linear congruential equation in n variables has |m|n−1 ·d
incongruent solutions.
5
2 Linear Diophantine Equations
2.1 Greatest Common Divisor
Definition 2.1.1. Given the integers a, b > 0, we define greatest common
divisor of a and b, as the largest number that divides both a and b. It is
denoted in two ways: (a, b) = c or gcd(a, b) = c. We will use (a, b) to denote
the greatest common divisor.
Example 2.1.1. Let’s find GCD of 15 and 35. The divisors are of 15;
±1, ±3, ±5, ±15,the divisors of 35 are;±1, ±5, ±7, ±35, and the common di-
visors of 15 and 35 are; ±1, ±5, and the greatest common divisor is 5, so
the gcd of 15 and 35 is 5 and by notation (15, 35) = 5.
Proof. Suppose that (a, b) = d and (a + cb, b) = k and we should prove that
d = k. If (a, b) = d, we can write a = dt and b = dp where t, p are any
integers.
If (a + cb, b) = k, then a + cb = km and b = kn where m, n are any integers.
In a + cb, we should write instead of a and b,a = dt and cb = cdp then
(dt + cdp, dp) = (d(t + cp), dp) and from this equality, it is clear that the gcd
of d(t+cp) and dp is equal to d, since d divide t+cp and p. So (a+cb, b) = d.
Hence we find d = k.
6
(3078, 76) = (190, 76)
For be sure of the equality, we must find the (3078, 76) and (190, 76)
76 = 22 · 19
190 = 2 · 5 · 19
3078 = 2 · 34 · 19.
Theorem 2.1.3. Given integers a, b > 0, then d = (a, b) is the least positive
integer that can be represented as ax + by and x, y integer numbers.
Proof. Assume that k is the smallest integer, k = ax+by. If d|a and d|b then,
d|ax + by, and also d ≤ k. k should divide a; otherwise a = uk + r, 0 < r < k
where u, r ∈ Z; r = a − uk = a − u(ax + by) = a(1 − ux) + b(−uy), so we
found another linear combination and r < k. It is a contradiction, because
our assumption was k is the smallest integer which can be represented as
ax + by. The process is same for proving that k|b.
Then, we get k ≤ (a, b) = d and k = d.
26 = 2 · 13
169 = 13 · 13
We find (26, 169) = 13.
If we choose x = 1, y = −6, we can write the equation below
Theorem 2.1.4. If a, b, m and n are integers, and if c|a and c|b, then
c|(ma + nb).
Proof. If c|a and c|b, we can find e and f are integers, a = ce, b = cf . Then,
ma + nb = mce + ncf = c(me + nf ). Hence, we saw that ma + nb is a
multiple of c. Thus, c|ma + nb.
7
Example 2.1.5. Assume that a = 16, b = 44 and c = 4
16 = 24
44 = 22 · 11.
So, 4 divides 16 and 44.
And assume that m = 6, n = −2, then
6 · 16 − 2 · 44 = 96 − 88 = 8.
Theorem 2.1.5. If a and b are positive integers, then the set of linear
combinations of a and b is the set of integer multiplies of (a, b).
Proof. Suppose that (a, b) = c. Let’s show that every linear combination
of a and b must also be a multiple of c. We know that (a, b) = c, then c|a
and c|b. Every linear combination of a and b is the form ma + nb and by
Theorem 2.1.4. we can see c|ma + nb, then ma + nb = ck. By Theorem
2.1.3. (a, b) = c can be represented a linear combination of a and b, there
are integers s.t. x and y, (a, b) can be written like; (a, b) = ax + by. If we
multiply both of sides with s, we get sc = sax + sby. Hence, we saw that
every multiple of c is a linear combination of a and b.
28 = 22 · 7
196 = 22 · 72
Then (28, 196) = 14.
For any x, y ∈ Z, there are some k values which provide the equation 28x +
196y = 14k. If we consider the which x and y give us k = 2.
28x + 196y = 14 · 2.
x + 7y = 1.
Definition 2.1.4. We will also define GCD for more than two integers.
Consider n integers, not all 0. The GCD is the largest number in the common
divisors. The notation is (a1 , a2 , . . . , an ).
8
Example 2.1.7. We can see (6, 9, 12) = 3 and (5, 35, 50) = 5.
Proof. Now, we have to find gcd of n integers. We know that any common
divisor of a1 , a2 , · · · , an−1 , an is also divisor of an−1 and an . If we say that
d1 = (an−1 , an ), it reduces to n − 1 integers a1 , a2 , · · · , an−2 , d1 . Also, any
common divisor of the n − 1 integers a1 , a2 , · · · , an−2 and (an−1 , an ) is com-
mon divisor of n integers, if it divides d1 = (an−1 , an ) and both of an−1 ,an .
The gcd of n integers, the gcd of first n − 2 integers and the gcd of the last
two integers are same, namely their gcd is equal.
256 = 28
342 = 2 · 32 · 19
578 = 2 · 172
1000 = 23 · 53
3472 = 24 · 7 · 31.
(256, 342, 578, 1000, 3472) = (256, 342, 578, (1000, 3472))
= (256, 342, 578, 8)
= (256, 342, (578, 8))
= (256, 342, 2)
= (256, (342, 2))
= (256, 2)
= 2.
9
mention the equation qd − e. We found the values of qd and e. If we put up
these values in the equation qd − e, we will find qd − e = qat − as = a(qt − s)
and a|qd − e, in other words a|r. Then a is a common divisor of d and r.
If b is a common divisor of d and r so b|dq + r, namely b|e. b is a common
divisor of d and e. b ≤ a and from definition of gcd we get a = (d, r)
27 = 6 · 4 + 3.
e = 27, d = 6, r = 3
6=2·3
27 = 33 .
(6, 27) = (6, 3) = 3.
a = b · q1 + r1 , 0 ≤ r1 < b
b = r1 · q2 + r2 , 0 ≤ r2 < r1
r1 = r2 · q3 + r3 , 0 ≤ r3 < r2
r2 = r3 · q4 + r4 , 0 ≤ r4 < r3
..
.
ri−1 = ri · qi+1 + ri+1 , 0 ≤ ri+1 < ri
10
..
.
rn−3 = rn−2 · qn−1 + rn−1 , 0 ≤ rn−1 < rn−2
rn−2 = rn−1 · qn + rn → (gcd), 0 ≤ rn < rn−1
rn−1 = rn · qn+1 + 0.
We will answer that why is the last nonzero remainder rn a common
divisor of a and b?
It is clear from the last line that rn divides rn−1 . Then the previous line
rn divides rn−2 , since it divides both rn−1 and rn , (we can see it by Lemma
2.1.1. (rn , rn−1 ) = (rn−1 , rn−2 )). Moving up to previous line, rn divides
rn−3 , since rn−3 divides rn−1 and rn−2 and (rn−3 , rn−2 ) = (rn−2 , rn−1 ). In
the middle line, we can see rn divides rn+1 , because of Lemma 2.1.1. says
(rn , rn−1 ) = (rn−1 , rn−2 ) = (rn−2 , rn−3 ) = · · · = (ri−1 , ri ) = (ri , ri+1 ).
Moving up line by line,when we arrive the second line we already know that
rn divides r2 and r1 , then (rn , rn−1 ) = (rn−1 , rn−2 ) = (rn−2 , rn−3 ) = · · · =
(r2 , r1 ) . Then the second line b = q2 · r1 + r2 tells us if rn divides r2
and r1 , also rn divides b, (rn , rn−1 ) = (rn−1 , rn−2 ) = (rn−2 , rn−3 ) = · · · =
(r2 , r1 ) = (r1 , b). And in conclusion rn divides r1 and b, so it divides also
a, by using Lemma 2.1.1. rn = (rn , rn−1 ) = (rn−1 , rn−2 ) = (rn−2 , rn−3 ) =
· · · = (r2 , r1 ) = (r1 , b) = (a, b).
Now, we know that the last nonzero remainder will be gcd, but now we must
answer that how do we know that we always get a remainder that equals to
0? When we compute a quotient with remainder, we get;
A = Q · B + R.
The remainder will be between 0 and B − 1. This is clear, since if R ≥ B,
then we can add one more to the quotient Q and substract B from R. So
the remainders will be decreasing;
b = r0 > r1 > r2 > r3 · · ·
But all of the remainders are greater than or equal to 0, so we have decreasing
sequence of nonnegative integers. After all we conclude remainder that
equals to 0 and it is clear that we will reach a remainder of 0 in at most b
steps.
442 = 128 · 3 + 58
128 = 58 · 2 + 12
58 = 12 · 4 + 10
12 = 10 · 1 + 2
10 = 2 · 5 + 0.
11
Euclidean algorithm says; the gcd of two variables is the last nonzero re-
mainder, in the question the last nonzero remainder is 2. Then (128, 442) = 2
If we have more than two variables and we want to find gcd, we can use
euclidean algorithm in connection with Theorem 2.1.6.
Example 2.2.2. Find (63, 217, 350, 728, 7077, 9100) using euclidean algo-
rithm.
(63, 217, 350, 728, (7077, 9100))
728 = 7 · 104 + 0
12
2.2.1 Extended Euclidean Algorithm
We already know how can we find the gcd of two numbers by euclidean
algorithm. Suppose that rn = (a, b) , a > b and
a = b · q1 + r1
b = r1 · q2 + r2
r1 = r2 · q3 + r3
r2 = r3 · q4 + r4
..
.
ri−1 = ri · qi+1 + ri+1
..
.
rn−3 = rn−2 · qn−1 + rn−1
rn−2 = rn−1 · qn + rn
rn−1 = rn · qn+1 + 0.
So,we get
(a, b) = k · ri + m · ri−1
Since,
13
ri = ri−2 − ri−1 · qi−1
So,we have
If we continue until the top line, we can find (a, b) as a linear combination
of a and b. The following theorem gives the induction method for finding
(a, b) as a linear combination of a and b.
k0 = 1, m0 = 0
k1 = 0, m1 = 1.
and
ki = ki−2 − qi−1 · ki−1 , mi = mi−2 − qi−1 · mi−1
for i = 2, 3, · · · , n where the qi are the quotients in the divisions of the
euclidean algorithm when it is used to find (a, b).
ri = ki · a + mi · b (1)
for i = 0, 1, · · · , n since (a, b) = rn , we mentioned the equation (1), we
know that
(a, b) = rn = kn · a + mn · b
If we use mathematical induction in equation (1),
For i = 0,
r0 = k0 · a + m0 · b
=1·a+0
= a.
14
For i = 1,
r1 = k1 · a + m1 · b
=0+1·b
= b.
ri = ki · a + mi · b
for i = 1, 2, · · · , p−1. Then, from the pth step of the euclidean algorithm,
we know
15
70 = 1470 − 140 · 10
= 1470 − (1670 − 1470) · 10
= 11 · 1470 − 1610
= 11 · (12740 − 1610 · 7) − 1610
= 11 · 12740 − 78 · 1610.
16
2.3 Linear Diophantine Equation
Definition 2.3.1. The diophantine equation is the polynomial equation
which the coefficients are integers and diophantine equations whose solutions
we seek in the set of integers or natural numbers. The most basic diophantine
equation is the linear case. We can write ax + by = c where a, b, c ∈ Z.
Theorem 2.3.1. Let a,b, and c be integers with a and b not both zero. The
linear diophantine equation
ax + by = c
(155, 45) = 5.
b a
x = x0 + n, y = y0 − n,
d d
where n is an integer.
Proof. We already know that there is a solution if and only if d|c by Theorem
2.3.1.
For the second part of the theorem, let x0 ,y0 be a particular solution
ax0 + by0 = c.
17
If we put
bn an
x = x0 + , y = y0 −
d d
bn an
ax + by = a(x0 + ) + b(y0 − ) = ax0 + by0 = c,
d d
so x, y are also solution.
We know from the previous Theorem 2.3.1., x and y integers since d
divides b and a. This gives us many solutions , for different integers n. Let’s
show that these are any solution; x, y be any integer solution, so ax+by = c.
Since ax + by = c = ax0 + by0 we have
a(x − x0 ) + b(y − y0 ) = 0,
so dividing by d we get
a b
(x − x0 ) = − (y − y0 ). (2)
d d
Now, a and b aren’t both 0, assume that b 6= 0. If we divide both the sides
with db and since ( ad , db ) = 1 , db divides x − x0 (by k|pr and (k, p) = 1, then
k|r). Thus x − x0 = bn d for some integer n, so x = x0 + d .
bn
b a a bn
− (y − y0 ) = (x − x0 ) = .
d d d d
b
So dividing by d (which is nonzero) we have
an
y = y0 − .
d
60x + 33y = 9.
18
60 = 1 · 33 + 27
33 = 1 · 27 + 6
27 = 4 · 6 + 3
6 = 2 · 3 + 0.
3 = 27 − 4 · 6
= 27 − 4 · (33 − 27)
= 5 · 27 − 4 · 33
= 5 · (60 − 33) − 4 · 33
= 5 · 60 − 9 · 33.
where n ∈ Z.
Now,we can extend the Theorem 2.3.2 with more than two variables.
19
Proof. Suppose that d = (a1 , a2 , . . . , an ) and d|c, we have many solutions.
Let’s use the mathematical induction.
For n = 2 we know that how we can find the solution of linear diophantine
equation by Theorem 2.3.2.
Suppose that there are infinitely many solutions for the equation in n = k
variables, then we can write a1 x1 + a2 x2 + · · · + ak xk = c and d|c.
The original equation in n = k + 1 variables can be reduced to a linear
diophantine equation in n variables. The equation in n = k + 1 variables;
a1 x1 + a2 x2 + · · · + ak xk + ak+1 xk+1 = t and d|t then, t = dp.
By Theorem 2.1.5., the set of linear combinations ak xk + ak+1 xk+1 is the
same as the set of multiplies of (ak , ak+1 ). So, for every integer p there
are many solutions of the linear diophantine equations ak xk + ak+1 xk+1 =
(ak , ak+1 )p. Then, the equation reduced to k variables.
By Theorem 2.1.6. c is divisible by (a1 , a2 , . . . , ak−1 , (ak , ak+1 )), this gcd
equals (a1 , a2 , . . . , ak , ak+1 ).
By the inductive hypothesis, this equation has many solution (it is also a lin-
ear diophantine equation has n variables) because gcd of a1 , a2 , . . . , an , an+1
divides c. We completed our proof and we see there are many solutions to
the original equation.
4w + 5z = 7
5=4·1+1
4 = 1 · 4 + 0.
1=5−4·1
w0 = −1, z0 = 1
20
Next we find x and y
x + 2y = −7 + 5k.
x = 1 · (−7 + 5k) + 2p
y = 0 · (−7 + 5k) − p
z = 7 − 4k
k, p = 0, ±1, ±2, . . .
4x + 8y + 5z = 7
4x + (8, 5)(8y + 5z) = 7
Assume that 8y + 5z = t
4x + t = 7
x0 = 0 and t0 = 1.
Then,
x=s
t = 7 − 4s
8=5·1+3
5=3·1+2
3=2·1+1
2 = 1 · 2 + 0.
21
1=3−2·1
= 3 − (5 − 3)
=2·3−1·5
= 2 · (8 − 5) − 5
= 2 · 8 − 3 · 5.
x=s
y = 2 · (7 − 4s) + 5m
= 14 − 8s + 5m.
z = −3 · (7 − 4s) − 8m
= −21 + 12s − 8m.
x = −7 + 5k + 2p,
y = −p,
z = 7 − 4k.
For y we have;
y = −p and y = 14 − 8s + 5m
−p = 14 − 8s + 5m
22
If we put s = 5k + 2p − 7 we get;
15p − 70 + 40k
−p = 14 − 40k − 16p + 56 + 5m ⇒ m = = 3p + 8k − 14
5
and if we put these values(s and m)in the z equality,we will see;
Hence,we get
7=7
57 = 22 · 2 + 13
22 = 13 · 1 + 9
13 = 9 · 1 + 4
9=4·2+1
4 = 1 · 4 + 0.
So, the last non zero remiander 1 and (57, 22) = 1 and 1|400, there are many
solutions.
23
1=9−4·2
= 9 − 2 · (13 − 9)
= 3 · 9 − 2 · 13
= 3 · (22 − 13) − 2 · 13
= 3 · 22 − 5 · 13
= 3 · 22 − 5 · (57 − 2 · 22)
= 13 · 22 − 5 · 57.
x = −2000 + 22n
y = 5200 − 57n.
Example 2.4.2. Assume that, there is discount for some stuffs in the restau-
rant and the pizza’s price changed from 57 SEK to 55 SEK. How many pizzas
and bottles of cola she can buy?
55 = 22 · 2 + 11
22 = 11 · 2 + 0.
(55, 22) = 11 and 11 doesn’t divide 400. So there is no solution.
Example 2.4.3. Peter wants to buy pets. He has 151 euros and he must
choose at least one of each pet. The prices are; fishes 3 euro each, cats are
5 euro each, dogs are 10 euros each. How many fishes, cats and dogs he can
buy?
24
3x + 5y + 10z = 151.
If we use the same method which have been used in Example 2.3.3, then we
write
(3, 5)3x + 5y + 10z = 151 and 3x + 5y = v.
v + 10z = 151
v = 151 + 10t
z = −t.
where t, k ∈ Z.
x, y, z should be bigger than zero, so we can find the ranges for t and k.
47 + 5k > 0,
2 + 2t − 3k > 0,
−t > 0.
k > −10,
2t − 3k > −2,
t > 0.
Now, we should find the ranges. For example, consider 2t − 3k > −2 and we
know that t a is negative parameter. So, if we put t = −1 in 2t − 3k > −2,
it is equal to (2 · −1) − 3k > −2 and k < 0. So, the ranges for k should
be −10 < k < 0 and let’s continue to process, if we choose t = −2 , the
inequality will be k < 0 again, and for t = −3, it will be k < −2 and if
we continue that calculation when we reach t = −16, we will get k < −10
and it will be wrong, because k should be bigger than −10. So, range for t
should be −16 < t ≤ −1. And the ranges are;
25
−16 < t ≤ −1.
If we choose t = −14, k can be only equal to −9, and if we put those values on
the x, y, z equation, we find x = 47 + 5(−9) = 2, y = 2 + 2(−14) − 3(−9) = 1
and z = −(−14) = 14. So he can buy 2 fishes, 1 cat and 14 dogs and he
pays 151 euros. If we choose the t values according to range, then k depends
on t.
We will find that how many solutions are there for these equations after the
theorem for solving linear congruence in n variables.
26
3 Linear Congruence
3.1 Introduction to Congruence
Definition 3.1.1. a, b, m ∈ Z and such that m > 0 if m|a − b, we say that
a is congruent to b modulo m. We denote it by
a ≡ b (mod m)
c(a − b) mt
=
d d
And we know from Theorem 2.1.1 if d = (c, m); then ( dc , m d ) = 1. Hence,
we can write ( dc )(a − b) = m
d t and m
d is a multiple of (a − b). Then, m
d |(a − b).
m
Namely, a ≡ b (mod d )
27
3.2 Linear Congruences
A linear congruence is an equation of the form ax ≡ b (mod m). Solving
this equation means identisfying which values of x satisfy it.
Theorem 3.2.1. Let a, b, c ∈ Z with a and b nonzero. If (x0 , y0 ) is a solution
to
ax + by = c
then x0 is a solution to the associated congruence
ax ≡ c (mod m)
where m = |b|.
Conversely, if x0 is a solution to the above congruence, then there is a
y0 such that (x0 , y0 ) is a solution to the above diophantine equation.
Proof. For the first part of theorem, observe that b divides (ax0 − c). Thus
m divides (ax0 − c).
For the second part of theorem, since x0 solve the congruence, m|(ax0 −
c). Thus ax0 − c is a multiple of b. Hence ax0 − c = y0 b for some y0 ∈ Z .
Then (x0 , y0 ) solves the Diophantine equation.
7x + 9y = 41 (3)
7x ≡ 41 (mod 9) (4)
which reduces to
7x ≡ 5 (mod 9) (5)
x = 2 + 9t (7)
28
y = 3 − 7t (8)
To complete solution to the equation (3) is given by equations (7) and (8),
where t is an arbitrary integer.
Example 3.2.2. Solve 7x ≡ 5 (mod 9) by using diophantine equation.
To find a solution, we need only obtain a solution of the linear diophantine
equation 7x − 9y = 5. The euclidean algorithm gives
9=7·1+2
7=2·3+1
3 = 3 · 1 + 0.
By extended euclidean algorithm
1=7−2·3
= 7 − 3 · (9 − 7)
= 4 · 7 − 3 · 9.
x0 = 4
y0 = 3.
29
for some t.
Among the several integers satisfying the first of these formulas, consider
those that result when t takes on the consecutive values, t = 0, 1, 2, · · · , d−1:
m 2m d−1
x0 , x0 + , x0 + , · · · , x0 + · m.
d d d
We claim that these integers are incongruent modulo m, and all other such
integers x are congruent to some one of them. If it happened that
m m
x0 + · t1 ≡ x0 + · t2 (mod m)
d d
Now, ( m
d , m) =
m
d and by Theorem 3.1.2 the factor m
d cancel to arrive at
the congruence
t1 ≡ t2 (mod d)
This shows that all values of set of incongruent solutions are by taking
x = x0 + ( m
d ) · t, where t ranges with a complete system of residues modulo
d. One set is given by x = x0 + m d · t, where t = 0, 1, 2, · · · , d − 1.
Proof. (a, m) = 1 and (a, m)|b. So, by Theorem 3.2.2, the congruence ax ≡ b
(mod m) has exactly (a, m) = 1 incongruent solution modulo m.
30
and x2 = 1+13·t2 . Suppose two solutions of this form are congruent modulo
13. If there is a unique solution ; it should be x1 = x2 (mod 13).
x1 ≡ x2 (mod 13)
1 + 13 · t1 ≡ 1 + 13 · t2 (mod 13)
13 · t1 ≡ 13 · t2 (mod 13).
t1 ≡ t2 (mod 1).
31
and s|b − an xn ⇔ b − an xn ≡ 0 (mod s).
It is clear, s|m ⇒ m s ∈ Z, therefore we can multiply the previous congruence
with m s . It results that
man mb m
xn ≡ (mod s ) (9)
s s s
which has ( mas n , s m m m
s ) = s (an , (a1 , · · · , an−1 , m)) = s (a1 , · · · , an−1 , an , m)
m 0
and s · d incongruent solutions for xn . Let xn be a particular solution of the
congruence (9). It results that a1 x1 + · · · + an−1 xn−1 ≡ b − an x0n (mod m)
has, assimilate to the induction’s hypothesis, s · mn−2 incongruent solutions
for x1 , · · · , xn−1 where s = (a1 , · · · , an−1 , m). Therefore the congruence
a1 x1 + · · · + an−1 xn−1 + an xn ≡ b (mod m) has m s ·d·s·m
n−2 = d · mn−1
Proof. Applying the above Theorem 3.2.4 with n = 2, we saw that there are
m2−1 · d, namely m · d incongruent solutions.
2x + 6y − 12z = 4
for some z.
(2, 6)x + 3y − 12z and if we say to w = x + 3y.
We get;
2w − 12z = 4 and simply w − 6z = 2, now we got the diophantine equation
in two variables.
The general solution is;
w = 8 + 6k
z =1+k
where k ∈ Z.
And then;
x + 3y = 8 + 6k
32
The general solution;
x = 8 + 3t
y = 2k − t
where t ∈ Z.
So, we found our general solution for x and y.
And t = 0, 1, · · · , 11 will produce incongruent values of x modulo 12. We
found y = 2k −t and in the linear diophantine it is equal to 3y = 3·(2k −t) =
6k − 3t. So if we choose k = 2 ,it will be equal to 12 and it repeat itself in
y mod 12. So, the all possibilities for y mod 12 by letting k = 0, 1. In this
question we have 12 t values and 2 k values, so we find 24 solutions. It is
also true with theorem, m = 12 and d = 2, we have 12 · 2 = 24 incongruent
solutions.
All incongruent solutions mod 12 are;
x = 8 + 3t
y = 2k − t
where t = 0, 1, · · · , 11 and k = 0, 1.
Example 3.2.7. And also,we can calculate the number of solution in Ex-
ample 2.4.3. Remember the question; 3x + 5y + 10z = 151 and if we write
as a linear congruence 3x + 5y ≡ 1 (mod | − 10|). If we use the theorem
3.2.4 for that question, a = 3, b = 5, c = 1 and m = 10. Since (3, 5, 10)|1,
then there is a solution. The number of solution mn−1 · d. In our question
m = 10 and d = 1 and we have two variables. 102−1 · 1 = 10, so we have 10
incongruent solution.We found that the general solution
x = 47 + 5k
x = 7 + 5k
y = 2 + 2t − 3k.
Hence k = 0, 1 produce incongruent values of x mod 10. Because if
k = 2, it will repeat itself in mod 10. And t = 5, it will be equal to 10 and
repeat itself. That’s why, the all possibilities for y mod 10 t = 0, 1, 2, 3, 4.
The incongruent solutions are;
x = 7 + 5k
y = 2 + 2t − 3k
33
where k = 0, 1 and t = 0, 1, 2, 3, 4.
Then, we have two k values and five t values. We find 5 · 2 = 10 values. It
confirms the Theorem 3.2.4.
34
4 Conclusion
As has been explained above, linear diophantine equation in two variables
can be solved by euclidean algorithm and extended euclidean algorithm.
When the solution has been searched for linear diophantine equation in two
variables, as ax + by = c, first should be checked (a, b)|c. If (a, b)|c, then
there is a solution. To find the solution for linear diophantine equation
in n variables, as a1 x1 + a2 x2 + · · · + an xn = c, again should be checked
(a1 , a2 , · · · , an )|c by mathematical induction.
The linear congruences and linear diophantine equations are relatable. As
seen above that the linear congruences in one variable ax ≡ b (mod m) can
be written ax − my = b as a linear diophantine equation in two variables.
We can generalize the method to more variable. The number of solutions
can be found to
a1 x1 + a2 x2 + · · · + an xn ≡ b (mod m)
as |m|n−1 d.
35
References
[1] J.Knig, Einleitung, Algebraischen Grszen Leipzig, 1903, 347-460
[13] Neville Robins, Beginning Number Theory, Jones And Barlett Publish-
ers, USA, 2006
[14] http://arxiv.org/ftp/math/papers.com
[15] http://www.math.cornell.edu
[16] http://public.csusm.edu
[17] http://math.buffalostate.edu
36
SE-351 95 Växjö / SE-391 82 Kalmar
Tel +46-772-28 80 00
dfm@lnu.se
Lnu.se/dfm