0% found this document useful (0 votes)
66 views5 pages

Task 4

The document contains 4 problems regarding number theory and linear congruences. Problem 1 involves computing the greatest common divisor of two numbers using the Euclidean algorithm, finding Bézout coefficients, and determining if a multiplicative inverse exists modulo m. Problem 2 involves finding values of x that satisfy two congruences, using the Chinese Remainder Theorem to solve a system of congruences, and proving a statement about the greatest common divisor of two expressions. Problem 3 discusses generating pseudorandom numbers using the linear congruential method and computing the first 15 terms of a sequence with given parameters. Problem 4 shows that a purely multiplicative linear congruential generator is equivalent to a specific recurrence

Uploaded by

Hernando Guzmán
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views5 pages

Task 4

The document contains 4 problems regarding number theory and linear congruences. Problem 1 involves computing the greatest common divisor of two numbers using the Euclidean algorithm, finding Bézout coefficients, and determining if a multiplicative inverse exists modulo m. Problem 2 involves finding values of x that satisfy two congruences, using the Chinese Remainder Theorem to solve a system of congruences, and proving a statement about the greatest common divisor of two expressions. Problem 3 discusses generating pseudorandom numbers using the linear congruential method and computing the first 15 terms of a sequence with given parameters. Problem 4 shows that a purely multiplicative linear congruential generator is equivalent to a specific recurrence

Uploaded by

Hernando Guzmán
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Problem 1.

[25 Marks]
(a) Use the Euclidean algorithm to compute the greatest common divisor of
23805 and 123. Include all workings.
Solution
Set up a division problem where a is larger than b.
Euclidean algorithm
a b = c with remainder R:Do the division.
Then replace a with b, replace b with R and repeat the division.
Continue the process until R = 0.
******************************************
23805 123 = 193 R = 66 (23805 = (193) (123) + 66)
123 66 = 1 R = 57 (123 = 1 (66) + 57)
66 57 = 1 R = 9 (66 = 1 (57) + 9)
57 9 = 6 R = 3 (57 = (6) (9) + 3)
9 3 = 3 R = 0 (9 = (3) (3) + 0)
When remainder R = 0, the gcd is the divisor, b, in the last equation. gcd = 3
gcd(23805; 123) = 3
(b) Using the backward-substitution method, use the sequence of quotients
and remainders from part (a) to compute the Bézout coe¢ cients s, t satis-
fying the equation 23805s + 123t = gcd(23805; 123). Include all workings.
Solution:
s 1; s 0 t 0; t 1
23805 123 = 193 R = 66 q = 193
s s q (s) = 1 193 (0) = 1 s s
t t q (t) = 0 193 (1) = 193 t t
123 66 = 1 R = 57 q=1
s s q (s) = 0 (1) (1) = 1 s s
t t q (t) = 1 193 ( 1) = 194 t t
66 57 = 1 R=9 q=1
s s q (s) = 1 (1) ( 1) = 2 s s
t t q (t) = 193 1 (194) = 387 t t
57 9=6 R=3 q=6
s s q (s) = 1 (6) (2) = 13 s s
t t q (t) = 194 6 ( 387) = 2516 t t
9 3=3 R=0
Since R = 0 the Bézout equation is
23805 ( 13) +123 (2516) = gcd(23805; 123) = 3
(c) Let m = 489 and a = 135. Can we compute a multiplicative inverse of a
modulo m? Explain why or why not, including workings. If we can compute a
multiplicative inverse, then compute it.
Solution
The multiplicative inverse of a modulo m exists if and only if a and m
are coprime (i.e., if gcd(a; m) = 1). If the modular multiplicative inverse of a
modulo m exists, the operation of division by a modulo m can be de…ned as
multiplying by the inverse. Zero has no modular multiplicative inverse.
Since 3j489 and 3j135 then gcd (489; 135) 6= 1 so, m = 489 and a = 135

1
there are not coprime then the multiplicative inverse of 135 modulo 489 not
exists.
Problem 2. [30 Marks]
(a) Find all values of x such that 13 x 250 and 67x + 12 78 mod 89
67x + 12 78 = 89a with a an integer
Solution
67x = 89a + 66 x = 89a+66
67 13 89a+66
67 250 then 871
89a + 66 16750
so, 937 89a 16684 10:52 a 187:46
hence, a is any integer such 10 a 187
Let A = x 2 R=x = 89a+66 67 ; with a 2 Z; 10 a 187
then all values of x such that 13 x 250 and 67x + 12 78 mod 89 are
the A set.
(b) Use Chinese Remainder Theorem to solve the following system of con-
gruences:
x 8 mod 13
for 0 x < 221: Show your workings.
x 15 mod 17
Solution
Since gcd(13; 17) = 1 ,
the Chinese Remainder TheoremIt tells us that the system has a unique
solution.
8
x = 13r + 8 0 13r + 8 < 221 13 r < 21313 0 r < 16
15 206
x = 17s + 15 0 17s + 15 < 221 17 s < 17 0 s < 12
17s + 15 = 13r + 8 r = 17s+7
13 0 s < 12
when s = 8 we obtain an integer r = 11 such the pair (11; 8) satis…es
x = 13r + 8
the system =) x = 151
x = 17s + 15
x 8 mod 13
so, the solution of system of congruences for 0 x <
x 15 mod 17
221
is x = 151
(c) Solve the following system of congruences:
Solution
4x y 9 mod 67 8x 2y 18 mod 67
=)
x + 2y 16 mod 67 x + 2y 16 mod 67
8x 2y = 67r + 18
9x = 67 (r + s) + 34
x + 2y = 67s + 16
x = 67(r+s)+34
9 2y = 67s + 16 x = 67s + 16 67(r+s)+34 9
18y = 603s + 144 67r 67s 34 = 536s 67r + 110
y = 536s 67r+110
18
x = 67(r+s)+34
Solution : 9 s; t 2 Z
y = 536s 67r+110
18
Problem 3. [10 Marks]
Prove the following statement.
Let n be any positive integer. The GCD of 3n + 2 and 5n + 3 is 1.

2
Hint: use a direct proof using Euclid.
Solution
(i) gcd(a; b) = gcd(b; a b)
Let d = gcd(a; b) then dja and djb so dj(a b) and djgcd(b; a b)
Let f = gcd(b; a b) hence f jb and f j(a b) so f j(b + (a b))
then f ja and f jgcd(a; b) . So d = f
(ii) gcd (n + 1; n) = 1
If n is a positive integer then , if dj (n + 1) and djn then dj [(n + 1) n]
then dj1 so d = 1
Now, we can to use (i) & (ii) to prove that gcd (3n + 2; 5n + 3) = 1
gcd (5n + 3; 3n + 2) = gcd (3n + 2; 2n + 1) = gcd (2n + 1; n + 1) = gcd (n + 1; n) =
1
so, gcd (5n + 3; 3n + 2) = 1
Problem 4. [25 Marks]
Pseudo-random numbers
Randomly generating numbers is a crucial subroutine of many algorithms in
computer science.
Because computers execute deterministic code, it is not possible (without
external in‡uence) to generate truly random numbers.
Hence, computers actually generate psuedo-random numbers.
The linear congruential method is a simple method for generating pseudo-
random numbers.
Let m be a positive integer and a be an integer 2 a < m, and c be an
integer
0 c < m.
A linear congruential method uses the following recurrence relation to de…ne
a sequence of pseudo-random numbers:
xn+1 = (axn + c) mod m
(a) Use the linear congruence method with a = 8; c = 5; and m = 14, to
compute the …rst 15 pseudo-random numbers when x0 = 1. That is, compute
x0 ; x1 ; :::; x14 .
Solution
xn+1 = (8xn + 5) mod 14 x0 = 1

3
n xn+1 = (8xn +5) mod 14 xn
0 1
1 x1 = (8x0 + 5 ) mod 14 13
2 x2 = (8x1 + 5) mod 14 11
3 x3 = (8x2 + 5) mod 14 9
4 x4 = (8x3 + 5) mod 14 7
5 x5 = (8x4 + 5) mod 14 5
6 x6 = (8x5 + 5) mod 14 3
7 x7 = (8x6 + 5) mod 14 1
8 x8 = (8x7 + 5) mod 14 13
9 x9 = (8x8 + 5) mod 14 11
10 x10 = (8x9 + 5) mod 14 9
11 x11 = 8 (x10 + 5) mod 14 7
12 x12 = (8x11 + 5) mod 14 5
13 x13 = (8x12 + 5) mod 14 3
14 x14 = (8x13 + 5) mod 14 1
(b) From part (a) we should notice that, with m = 14, the sequence does
not contain all 14 numbers in the set Z14 . In particular because the sequence is
periodic.
Using m = 8, determine the value of a which does give all 8 possible numbers
before repeating. For your choice of a, which choices of c give all 8 possible
numbers?
For each a; c pair which give all 8 possible numbers, give the terms of the
sequence x0 ; :::; x7 with x0 = 1
Solution
xn+1 = (axn + c) mod 8 with a = 5 c = 1 we have the following sequence
n xn+1 = (5xn +1) mod 8 xn
0 1
1 x1 = (x0 +1) mod 8 6
2 x2 = (x1 +1) mod 8 7
3 x3 = (x2 +1) mod 8 4
4 x4 = (x3 +1) mod 8 5
5 x5 = (x4 +1) mod 8 2
6 x6 = (x5 +1) mod 8 3
7 x7 = (x6 +1) mod 8 0
Now if a = 2 then the values of c = 1; 3; 5; 7 generate the set Z8
(a; c) sequence
(5; 1) 1; 6; 7; 4; 5; 2; 3; 0
(5; 3) 1; 0; 3; 2; 5; 4; 7; 6
(5; 5) 1; 2; 7; 0; 5; 6; 3; 4
(5; 7) 1; 4; 3; 6; 5; 0; 7; 2
(c) When c = 0, a linear congruence generator is called a purely mul-
tiplicative generator. Consider the generator de…ned by:
xn+1 = (65539xn ) mod 231
Show that, modulo 231 , this purely multiplicative generator is equivalent to
the recurrence relation:xi+2 = 6xi+1 9xi Hint: 65539 = 216 + 3

4
Solution
We can see that module 231 we have that
(6xi+1 9xi ) = 6 65539xi + k231 9xi with k 2 Z
(6xi+1 9xi ) = 6 216 + 3 xi + 6k231 9xi = 6 216 xi + 18xi 9xi + 6k231
(6xi+1 9xi ) = 6 216 xi + 9xi (a)
We can see too that module 231
xi+2 = 65539xi+1 + h231 with h 2 Z
xi+2 = 216 + 3 xi+1 + h231
xi+2 = 216 + 3 216 + 3 xi + m231 + h231 with m 2 Z
2
xi+2 = 216 + 3 xi + z231 with z = m 216 + 3 + h
32 16
so, xi+2 = 2 + 6 2 + 9 xi + z231 = 6 216 xi + 9xi + (z + 2) 231
16
then, xi+2 = 6 2 xi + 9xi (b)
Hence, for (1) and (2) we obtain that
xi+2 = 6xi+1 9xi

You might also like