Lu 1-la/b]]-L 4700 The loop stops when it gets to [gcd (a, b) 0]. He proposed the following program: gcd(a,b): while (b): [a b]=[a b][/b] return a [m11 m121 If the inputs are the coprime N and x, the gcd() will satisfy: [10] = [N x] [m21 m22] 212] is the result of the matrix multiplications after several iterations: [m11 m121 where M = [m21 m22] M = m11 m -- m12] Lm21 m22] = 1 1 a/b/b] 1 Since m11*N + m21*x = 1, we have m21*x % N = 1, that is, m21 is the multiplicative inverse of x modulo N. Then, the program to compute the matrix M is proposed as mul inverse (N, x | N and x are coprime): [a b] = [N_x] M = · 66 9 while (be): M = M* M*[1₁ab] [a b] = [a b][/b] return M[2,1] Prove the correctness of the program by axiomatic semantics. Problem 2. The multiplicative inverse of an integer x modulo N where x and N are coprime (mutually prime), is an integer m < N such that mx % N = 1. A function prototype is given as: Input: unsigned int x, unsigned int N, where x and N are coprime. Output: unsigned int m, where m < N and mx % N = 1. Mathematically, mx % N = 1 is equivalent to mx + kN = 1 = gcd (x, N). The problem of finding multiplicative inverse becomes an application of the gcd problem. Recall that the gcd is solved by the Euclid's algorithm: Base case: gcd (a,b) = a, if b = 0 Recursion: gcd (a,b) = gcd (b, a%b) otherwise و A student realized that the gcd can be computed iteratively, using the property 1 [a b] [ab]] = [b_ab] The loop stops when it gets to [gcd (a, b) 0]. He proposed the following program: gcd (a,b): while (b): ab=a bab return a If the inputs are the coprime N and x, the gcd() will satisfy: [10] = [N x] where M = m11 m12 Lm21 m22] [m11 m12] [m21 m22] is the result of the matrix multiplications after several iterations: m12 Lm21 m22] M = [m11 m²] = [1 a/b₁ab]-[1 1 -lak/bk]]

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Lu
1-la/b]]-L
4700
The loop stops when it gets to [gcd (a, b) 0]. He proposed the following program:
gcd(a,b):
while (b):
[a b]=[a b][/b]
return a
[m11 m121
If the inputs are the coprime N and x, the gcd() will satisfy: [10] = [N x]
[m21 m22]
212] is the result of the matrix multiplications after several iterations:
[m11 m121
where M =
[m21 m22]
M = m11 m --
m12]
Lm21 m22]
=
1
1
a/b/b]
1
Since m11*N + m21*x = 1, we have m21*x % N = 1, that is, m21 is the multiplicative
inverse of x modulo N. Then, the program to compute the matrix M is proposed as
mul inverse (N, x | N and x are coprime):
[a b] = [N_x]
M =
· 66 9
while (be):
M = M*
M*[1₁ab]
[a b] = [a b][/b]
return M[2,1]
Prove the correctness of the program by axiomatic semantics.
Transcribed Image Text:Lu 1-la/b]]-L 4700 The loop stops when it gets to [gcd (a, b) 0]. He proposed the following program: gcd(a,b): while (b): [a b]=[a b][/b] return a [m11 m121 If the inputs are the coprime N and x, the gcd() will satisfy: [10] = [N x] [m21 m22] 212] is the result of the matrix multiplications after several iterations: [m11 m121 where M = [m21 m22] M = m11 m -- m12] Lm21 m22] = 1 1 a/b/b] 1 Since m11*N + m21*x = 1, we have m21*x % N = 1, that is, m21 is the multiplicative inverse of x modulo N. Then, the program to compute the matrix M is proposed as mul inverse (N, x | N and x are coprime): [a b] = [N_x] M = · 66 9 while (be): M = M* M*[1₁ab] [a b] = [a b][/b] return M[2,1] Prove the correctness of the program by axiomatic semantics.
Problem 2. The multiplicative inverse of an integer x modulo N where x and N are coprime (mutually
prime), is an integer m < N such that mx % N = 1. A function prototype is given as:
Input: unsigned int x, unsigned int N, where x and N are coprime.
Output: unsigned int m, where m < N and mx % N = 1.
Mathematically, mx % N = 1 is equivalent to mx + kN = 1 = gcd (x, N). The problem of
finding multiplicative inverse becomes an application of the gcd problem. Recall that the gcd
is solved by the Euclid's algorithm:
Base case: gcd (a,b) = a, if b = 0
Recursion:
gcd (a,b)
=
gcd (b, a%b) otherwise
و
A student realized that the gcd can be computed iteratively, using the property
1
[a b] [ab]] = [b_ab]
The loop stops when it gets to [gcd (a, b) 0]. He proposed the following program:
gcd (a,b):
while (b):
ab=a bab
return a
If the inputs are the coprime N and x, the gcd() will satisfy: [10] = [N x]
where M
=
m11
m12
Lm21 m22]
[m11
m12]
[m21 m22]
is the result of the matrix multiplications after several iterations:
m12
Lm21 m22]
M = [m11 m²] = [1 a/b₁ab]-[1
1
-lak/bk]]
Transcribed Image Text:Problem 2. The multiplicative inverse of an integer x modulo N where x and N are coprime (mutually prime), is an integer m < N such that mx % N = 1. A function prototype is given as: Input: unsigned int x, unsigned int N, where x and N are coprime. Output: unsigned int m, where m < N and mx % N = 1. Mathematically, mx % N = 1 is equivalent to mx + kN = 1 = gcd (x, N). The problem of finding multiplicative inverse becomes an application of the gcd problem. Recall that the gcd is solved by the Euclid's algorithm: Base case: gcd (a,b) = a, if b = 0 Recursion: gcd (a,b) = gcd (b, a%b) otherwise و A student realized that the gcd can be computed iteratively, using the property 1 [a b] [ab]] = [b_ab] The loop stops when it gets to [gcd (a, b) 0]. He proposed the following program: gcd (a,b): while (b): ab=a bab return a If the inputs are the coprime N and x, the gcd() will satisfy: [10] = [N x] where M = m11 m12 Lm21 m22] [m11 m12] [m21 m22] is the result of the matrix multiplications after several iterations: m12 Lm21 m22] M = [m11 m²] = [1 a/b₁ab]-[1 1 -lak/bk]]
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education