C960 Discrete Math II Unit 2 Number Theory and Cryptography (Flashcards with solutions)
2.16.1: Converting from decimal to non-decimal bases A number N is given below in decimal format. Compute the representation of N in the indicated base N = 344, hex
(158)₁₆ 344 mod 16 = 8 344 div 16 = 21 21 mod 16 = 5 21 div 16 = 1 1 mod 16 = 1 1 div 16 = 0 344 = (158)₁₆
2.16.1: Converting from decimal to non-decimal bases A number N is given below in decimal format. Compute the representation of N in the indicated base N =136, base 7
(253)₇ 136 mod 7 = 3 136 div 7 = 19 19 mod 7 = 5 19 div 7 = 2 2 mod 7 = 2 2 div 7 = 0 136 = (253)₇
2.11.2: Extended Euclidean Algorithm The two linear equations above can be used to express GCD(225, 60) as a linear combination of 225 and 60: 15 = C · 225 + D · 60 What is the correct value for C?
-1 15 = 60 - 45. 45 = 225 - (3 · 60) The second equation replaces 45 in the first equation with a linear combination of 225 and 60.15 = 60 - (225 - 3 · 60) = 4·60 - 225The coefficient of 225 is -1.
2.3.3: Computing div and mod. -13 div 6
-3 Starting with -13, 6 is added 3 times until the result yields a number in the range from 0 through 5.-13 + 3 · 6 = 5-13 = -3 · 6 + 5
2.3.1: Compute divisor and modulus. (-215) div 7
-31 (−215) = (−31)·7 + 2, so (−215) div 7 = −31.
2.11.1: Euclid Algorithm Enter the number to complete the linear combination. GCD(50, 44) yields sequence: 50 44 6 2 0 6 = 50 − 1 ⋅ 44 2 = 44 − 7 ⋅ 6 After substitution: 2=44 − 7 ⋅ (50 − 1 ⋅ 44) 2 = ? ⋅ 50 + ? ⋅44 Solve ?
-7, 8
2.5.1: Compute expression using modular arithmetic [(34 mod 6 )(72 mod 6)] mod 6
0
2.5.1: Compute expression using modular arithmetic. [27 · 70] mod 7
0
2.5.1: Computing using modular arithmetic (77 · (−65) + 147) mod 7
0 (77 · (−65) + 147) mod 7 = ((77 mod 7) · (−65) + (147 mod 7)) mod 7 = (0 · (−65) + 0) mod 7 = 0
2.3.3: Computing div and mod. -10 mod 5
0 Starting with -10, when 5 is added 2 times to -10, the result is 0, which is in the range from 0 through 4.-10 + 2 · 5 = 0-10 = -2 · 5 + 0
2.10.2: Euclid's Algorithm Consider an Euclid's algorithm with input integers y = 156 and x = 54 What is the value of r after the second iteration of the loop in Euclid's algorithm?
0 x = 48, y = 6, r = 48 mod 6 = 0
2.9.2: Finding a random number Consider a random integer selected from the range from 2 to 1,000,000,000,000. Approximately, what are the chances that the selected number is prime?
0.036 The chances the selected number is prime is 1/ln(1,000,000,000,000) which is approximately 0.036.
2.11.2: Extended Euclidean Algorithm Write GCD of 225 and 60 as a linear combination of those two numbers 15 = 60 - (A * 45) 45 = 225 - (B * 60) What's A?
1 A = 60 div 45 = 1
2.19.1: Fast exponentiation 5³⁵ mod 11
1 Refer to book for solution
2.12.1: Multiplicative inverses mod n ? * 10 mod 11 = 1
10 10 · 10 mod 11 = 100 mod 11 = 1
2.15.1: Converting from hex to binary Give a binary representation for each number given below in hex. Drop the leading zeroes in your binary representation. (A3)₁₆
10100011 (A)₁₆ = (1010)₂ (3)₁₆ = (0011)₂
2.16.2: Conversion to expansion base b Find the binary of 21
10101 21 mod 2 = 1; Rightmost bit is 1. 21 div 2 = 10 10 mod 2 = 0; Next bit to the left is 0. 10 div 2 = 5 5 mod 2 = 1; Next bit to the left is 1. 5 div 2 = 2 2 mod 2 = 0; Next bit to the left is 0. 2 div 2 = 1 1 mod 2 = 1; Next bit to the left is 1. 1 div 2 = 0
2.15.1: Converting from hex to binary (2A0B)₁₆
10101000001011 (2)₁₆= (0010)₂ (A)₁₆ = (1010)₂ (0)₁₆ = (0000)₂ (B)₁₆ = (1011)₂
2.15.1: Hexadecimal expansions What is the binary expansion of (2F)₁₆? Omit the leading zeroes in your answer.
101111 0010 corresponds to 2 and 1111 corresponds to F. Put 0010 and 1111 together to get 00101111 and drop the leading zeroes to get 101111.
2.14.2: Converting to decimal expansion. (1100110)₂
102 2⁶ + 2⁵ + 2² + 2¹ = 102
2.16.2: Conversion to expansion base b Find the expansion base 7 of 52
103 52 mod 7 = 3; Rightmost digit is 3. 52 div 7 = 7 7 mod 7 = 0; Next digit to the left is 0. 7 div 7 = 1 1 mod 7 = 1; Next digit to the left is 1. 1 div 7 = 0
2.18.3: An execution of the iterative algorithm for fast exponentiation Consider the algorithm for iterative fast exponentiation on input x = 3 and y = 13 What is the binary representation of 13?
1101
2.16.1: Converting from decimal to non-decimal bases A number N is given below in decimal format. Compute the representation of N in the indicated base N = 217, binary
11011001 217 mod 2 = 1 217 div 2 = 108 108 mod 2 = 0 108 div 2 = 54 54 mod 2 = 0 54 div 2 = 27 27 mod 2 = 1 27 div 2 = 13 13 mod 2 = 1 13 div 2 = 6 6 mod 2 = 0 6 div 2 = 3 3 mod 2 = 1 3 div 2 = 1 1 mod 2 = 1 1 div 2 = 0 217 = (11011001)₂
2.15.1: Converting from hex to binary (1FC)₁₆
111111100 (1)1₁₆ = (0001)₂ (F)₁₆ = (1111)₂ (C)₁₆ = (1100)₂
2.11.1: Euclid Algorithm Fill in the missing numbers of the sequence generated by Euclid's algorithm on inputs 94 and 16. GCD(94, 16) yields sequence: 94 16 ? ? 0 Solve ?
14, 2 94 mod 16 = 14 16 mod 14 = 2
2.16.1: Converting a decimal number to its base b expansion Find the base 6 expansion of 67
151 67 div 6 = 11 67 mod 6 = 1 11 div 6 = 1 11 mod 6 = 5 1 div 6 = 0 1 mod 6 = 1
2.14.2: Converting to decimal expansion. (10)₁₇
17 (1 * 17¹) + (0 * 17⁰)
2.14.2: Converting to decimal expansion (346)₇
181 (3 * 7²) + (4 * 7¹) + ( 6 * 7⁰) = 181
2.15.2: Converting from binary to hex Give a hexadecimal representation for each number given below in binary. 11101
1D
2.3.1: Compute divisor and modulus. (-215) mod 7
2 (−215) = (−31)·7 + 2, so (−215) mod 7 = 2.
2.5.1: Computing using modular arithmetic 38⁷ mod 3
2 387 mod 3 = (38 mod 3)7 mod 3 = (27) mod 3 = 128 mod 3 = 2
2.10.2: Euclid's Algorithm Consider an Euclid's algorithm with input integers y = 156 and x = 54 How many times does the loop in Euclid's algorithm execute on input 156 and 54?
2 After the second iteration of the loop, r = 0, so the loop executes two times
2.19.1: An execution of the iterative algorithm for fast modular exponentiation. Consider the algorithm for iterative fast exponentiation on input x = 3, y = 13, and n = 7. The mod operations are not applied to the variable r. For exponent y = 13, (r mod 2) = 1 at the beginning of iterations 1, 3, and 4. What is the value of s at the beginning of the fourth iteration?
2 At the beginning of the third iteration, s = 4. During the third iteration, s := s² mod 7 = 4² mod 7 = 2.
2.19.1: An execution of the iterative algorithm for fast modular exponentiation. Consider the algorithm for iterative fast exponentiation on input x = 3, y = 13, and n = 7. The mod operations are not applied to the variable r. For exponent y = 13, (r mod 2) = 1 at the beginning of iterations 1, 3, and 4. At the beginning of the first iteration s = x = 3. What is the value of s at the beginning of the second iteration?
2 During the first iteration, s := s² mod 7 = 3² mod 7 = 2.
2.8.2: Finding expressions for the GCD and LCM from prime factorizations. 315 = 3² * 5 * 7 550 = 2 * 5² * 11 LCM(315, 550) in exponential form
2 * 3² * 5² * 7 * 11 315 = 2⁰·3²·5¹·7¹ 550 = 2¹·3⁰·5²·7⁰·11¹ GCD(550, 315) = ₂max{0,1}·₃max{0, 1}·₅max{2,0}·₇max{1,0}·₁₁max{0,1}
2.8.1: Computing using prime factorizations 25480 = 2³ * 5 * 7² * 13 140 = 2² * 5 * 7 25480/140 in exponential form
2 * 7 * 13 = 182
2.8.1: Computing using prime factorizations 1078 = 2 * 7² * 11 25480 = 2³ * 5 * 7² * 13 GCD(1078, 25480) in exponential form
2 * 7² = 98
2.14.2: Converting to decimal expansion. (50020)₈
20496 (5·8⁴) + (2·8¹) = 20496
2.16.2: Conversion to expansion base b Find the expansion base 5 of 57
212 57 mod 5 = 2; Rightmost digit is 2. 57 div 5 = 11 11 mod 5 = 1; Next digit to the left is 1. 11 div 5 = 2 2 mod 5 = 2; Next digit to the left is 2. 2 div 5 = 0
2.19.1: Fast exponentiation 11²⁰ in Z₃₃
22 Refer to book for solution
2.12.1: Computing a multiplicative inverse For each x and n, find the multiplicative inverse mod n of x. Your answer should be an integer s in the range 0 through n - 1. Check your solution by verifying that sx mod n = 1 x = 77, n = 52
25 GCD(77, 52) = 1 = 25·77 - 37·52 The coefficient of 77 in the equation above is 25. The multiplicative inverse of 77 mod 52 is (25 mod 52) = 25. Check: 77·25 mod 52 = 1925 mod 52 = 1
2.12.2: Find the multiplicative inverse using the results of the Extended Euclid's algorithm returnsGCD(14, 33) = 1 = 3 · 33 - 7 · 14.What is the multiplicative inverse of 14 in Z₃₃ ?
26 -7 is the coefficient of 14 in the equation:1 = 3 · 33 - 7 · 14The inverse of 14 in Z₃₃ is (c mod 33), where c is the coefficient of 14:-7 mod 33 = 26
2.12.2: Find the multiplicative inverse using the results of the Extended Euclidean Algorithm. Euclid's algorithm returnsGCD(61, 54) = 1 = 26 · 54 - 23 · 61 What is the multiplicative inverse of 54 mod 61?
26 26 is the coefficient of 54 in the equation:1 = 26 · 54 - 23 · 61The inverse of 54 mod 61 is (c mod 61), where c is the coefficient of 54:26 mod 61 = 26
2.15.2: Converting from binary to hex Give a hexadecimal representation for each number given below in binary. 101101101000010101
2DA15
2.8.1: GCD and LCM from prime factorizations. LCM(924, 33075) in exponential form 924 = 2² * 3¹ * 5⁰ * 7¹ * 11¹ 33075 = 2⁰ * 3³ * 5² * 7² * 11⁰
2² * 3³ * 5² * 7² * 11¹ = 1455300 The LCM is obtained by taking the larger of the exponents of each prime from 924 and 33075, which results in LCM(924,33075) = 2² * 3³ * 5² * 7² * 11¹ = 1455300
2.8.1: Computing using prime factorizations 175 = 5² * 7 25480 = 2³ * 5 * 7² * 13 LCM(175 , 25480) in exponential form
2³ * 5² * 7² * 13 = 127400
2.8.1: Computing using prime factorizations 175 = 5² * 7 25480 = 2³ * 5 * 7² * 13 175 * 25480 in exponential form
2³ * 5³ * 7³ * 13 = 4459000
2.7.1: Prime factorizations. In which prime factorization are the prime factors listed in non-decreasing order? 2·7·13·11 2·7·11·13 7·2·11·13
2·7·11·13 Each prime factor is greater than or equal to the one that precedes it.
2.8.1: GCD and LCM from prime factorizations. GCD(924, 33075) in exponential form 924 = 2² * 3¹ * 5⁰ * 7¹ * 11¹ 33075 = 2⁰ * 3³ * 5² * 7² * 11⁰
2⁰ * 3¹ * 5⁰ * 7¹ * 11⁰ = 21 The GCD is obtained by taking the smaller of the exponents of each prime from 924 and 33075, which results in GCD(924, 33075) = 2⁰ * 3¹ * 5⁰ * 7¹ * 11⁰ = 21
2.7.1: Prime factorizations What is the prime factorization for 48 in exponential form?
2⁴ * 3 = 48. Also, 2 and 3 are both prime numbers.
2.19.1: An execution of the iterative algorithm for fast modular exponentiation. Consider the algorithm for iterative fast exponentiation on input x = 3, y = 13, and n = 7. The mod operations are not applied to the variable r. For exponent y = 13, (r mod 2) = 1 at the beginning of iterations 1, 3, and 4. Starting with p = 1, the value for p is multiplied by s mod 7 in each iteration in which (r mod 2) = 1. What is the final value for p?
3 (r mod 2) = 1 during iterations 1, 3, and 4. The value of s at the beginning of iterations 1, 3, and 4 are 3, 4, and 2. The final value for p is 3 · 4 · 2 mod 7 = 24 mod 7 = 3.
2.11.2: Extended Euclidean Algorithm Write GCD of 225 and 60 as a linear combination of those two numbers 15 = 60 - (A * 45) 45 = 225 - (B * 60) What's B?
3 B = 225 div 60 = 3
2.8.2: Finding expressions for the GCD and LCM from prime factorizations. 147 = 3 * 7² 315 = 3² * 5 * 7 GCD(147,315) in exponential form
3 * 7 147 = 3¹ * 5⁰ * 7² 315 = 3² * 5¹ * 7¹ GCD(147, 315) = ₃min{1,2}·₅min{0,1}·₇min{2,1} = 3 · 7
2.7.1: Prime factorizations What is the prime factorization for 31?
31 31 is a prime number, so its prime factorization is itself.
2.8.2: Finding expressions for the GCD and LCM from prime factorizations. 147 = 3 * 7² 315 = 3² * 5 * 7 LCM(147, 315) in exponential form
3² * 5 * 7² 147 = 3¹ * 5⁰ * 7² 315 = 3² * 5¹ * 7¹ ₃max{1,2}·₅max{0,1}·₇max{2,1} = 3 · 7
2.5.1: Compute expression using modular arithmetic [26¹⁹ + 13] mod 5
4
2.5.1: Computing using modular arithmetic (72 · (−65) + 211) mod 7
4 (72 · (−65) + 211) mod 7 = ((72 mod 7) · (−65 mod 7) + (211 mod 7)) mod 7 = (2 · 5 + 1) mod 7 = 11 mod 7 = 4
2.11.2: Extended Euclidean Algorithm The two linear equations above can be used to express GCD(225, 60) as a linear combination of 225 and 60: 15 = C · 225 + D · 60 What is the correct value for D?
4 15 = 60 - 45 45 = 225 - (3 · 60) The second equation replaces 45 in the first equation with a linear combination of 225 and 60. 15 = 60 - (225 - 3·60) = 4·60 - 225. The coefficient of 60 is 4.
2.3.1: Compute divisor and modulus. 344 mod 5
4 344 = 68·5 + 4, so 344 mod 5 = 4.
2.19.1: An execution of the iterative algorithm for fast modular exponentiation. Consider the algorithm for iterative fast exponentiation on input x = 3, y = 13, and n = 7. The mod operations are not applied to the variable r. For exponent y = 13, (r mod 2) = 1 at the beginning of iterations 1, 3, and 4. What is the value of s at the beginning of the third iteration?
4 At the beginning of the second iteration, s = 2.During the second iteration, s := s² mod 7 = 2² mod 7 = 4
2.19.1: Fast exponentiation 5⁶⁸ mod 7
4 Refer to book for solution
Lesson 2.5.2 Computing arithmetic expressions modulo n. (43¹⁷+32*130) mod n 7
4 The value of the expression (43¹⁷+32*139) mod 7 does not change if 43, 32, and 139 are replaced by 43 mod 7, 32 mod 7, and 139 mod 7. The value of the expression is therefore (1¹⁷+4*6) mod 7. (43¹⁷+32*139) mod 7 is equal to (1+24) mod 7=25 mod 7=4
2.11.1: Euclid Algorithm Enter the number to complete the linear combination. GCD(87, 18) yields sequence: 87 18 15 3 0 15 = 87 - ? * 18 3 = 18 - ? * 15 Solve ?
4, 1 87 div 18 = 4 18 div 15 =1
2.12.1: Computing a multiplicative inverse For each x and n, find the multiplicative inverse mod n of x. Your answer should be an integer s in the range 0 through n - 1. Check your solution by verifying that sx mod n = 1 x = 52, n = 77
40 77 52 25 2 1 77 mod 52 = 25 52 mod 25 = 2 25 mod 2 = 1 The equations for substitution are: 1 = 25 - 12·2 2 = 52 - 2·25 25 = 77 - 52 Substitute (52 - 2·25) for 2 into the equation 1 = 25 - 12·2 1 = 25 - 12·(52 - 2·25) = 25·25 - 12·52 Substitute (77 - 52) for 25 into the equation 1 = 25·25 - 12·52 1 = 25·(77 - 52) - 12·52 = 25·77 - 37·52 GCD(77, 52) = 1 = 25·77 - 37·52 The coefficient of 52 in the equation above is -37. The multiplicative inverse of 52 mod 77 is (-37 mod 77) = 40. Check: 52·40 mod 77 = 2080 mod 77 = 1
2.15.1: Hexadecimal expansions What is the decimal expansion of (2F)₁₆?
47 2 · 16¹ + 15 · 16⁰ = 47
2.10.2: Euclid's Algorithm Consider an Euclid's algorithm with input integers y = 156 and x = 54 What is the value of r at the beginning of the first iteration of the loop in Euclid's algorithm?
48 r = 156 mod 54 = 48
2.15.2: Converting from binary to hex Give a hexadecimal representation for each number given below in binary. 101
5
2.5.1: Compute expression using modular arithmetic. [(47 mod 6) + (36 mod 6)] mod 6
5
2.8.2: Finding expressions for the GCD and LCM from prime factorizations. 315 = 3² * 5 * 7 550 = 2 * 5² * 11 GCD(315, 550) in exponential form
5 315 = 2⁰ * 3² * 5¹ *7¹ * 11⁰ 550 = 2¹ * 3⁰ * 5² * 7⁰ * 11¹ GCD(550, 315) =₂min{0,1}·₃min{0, 1}·₅min{1,2}·₇min{1,0}·₁₁min{0,1}
2.12.1: Multiplicative inverses mod n ? * 9 mod 11 = 1
5 5 · 9 mod 11 = 45 mod 11 = 1
2.3.3: Computing div and mod. -13 mod 6
5 Starting with -13, when 6 is added 3 times to -13, the result is 5, which is in the range from 0 through 5.-13 + 3 · 6 = 5-13 = -3 · 6 + 5
2.14.2: Converting to decimal expansion. (120121)₃
541 1·3⁵ + 2·3⁴ + 1·3² + 2·3¹ + 1·3⁰ = 243 + 2·81 + 9 + 2·3 + 1 = 421
2.16.3: Number of digits base b How many digits are required to express the binary expansion of 2⁵⁵?
56 The binary expansion of 2⁵⁵ is a 1 followed by 55 0's.
2.14.1: Converting a number base b into its decimal expansion (2012)₃
59 (2 * 3³) + (0 * 3²) + (1 * 3¹) + (2 * 3⁰) = 59
2.15.1: Hexadecimal expansions What is the hexadecimal number that corresponds to 1011101?
5D The rightmost four bits, 1101, corresponds to D. The remaining bits on the left are 101. Add a leading zero to 101 on the left to get 0101 which corresponds to 5. Therefore 1011101 corresponds to a hexadecimal expansion of 5D.
2.18.2: Expressing exponents as products of terms whose exponents are powers of 2. 7 = 2² + 2¹ + 2⁰ Which expression is equivalent to 5⁷?
5^2^2 * 5^2^1 * 5^2^0 5⁴⁺²⁺¹ = 5⁷
2.10.2: Euclid's Algorithm Consider an Euclid's algorithm with input integers y = 156 and x = 54 What is the GCD of 156 and 54?
6 After the last iteration of the loop, y = 54, x = 6, and r = 0. Therefore the GCD is x = 6.
2.10.2: Euclid's Algorithm Consider an Euclid's algorithm with input integers y = 156 and x = 54 What is the value of r at the beginning of the second iteration of the loop in Euclid's algorithm?
6 x = 54, y = 48, r = 54 mod 48 = 6
2.9.1: Estimating the number of primes Use the prime number theorem to give an approximation for the number of prime numbers in the range 2 through 10,000,000
620421 10,000,000 = 10⁷. The number of prime numbers in the range 2 through 10⁷ is approximately 10⁷/ln(10⁷) ≈ 620421.
2.12.1: Computing a multiplicative inverse For each x and n, find the multiplicative inverse mod n of x. Your answer should be an integer s in the range 0 through n - 1. Check your solution by verifying that sx mod n = 1 x = 53, n = 71
67 71 53 18 17 1 71 mod 53 = 18 53 mod 18 = 17 18 mod 17 = 1 The equations for substitution are: 1 = 18 - 17 17 = 53 - 2·18 18 = 71 - 53 Substitute (53 - 2·18) for 17 into the equation 1 = 18 - 17 1 = 18 - (53 - 2·18) = 3·18 - 53 Substitute (71 - 53) for 18 into the equation 1 = 3·18 - 53 1 = 3·(71 - 53) - 53 = 3·71 - 4·53 GCD(71, 53) = 1 = 3·71 - 4·53 The coefficient of 53 in the equation above is -4. The multiplicative inverse of 53 mod 71 is (-4 mod 71) = 67. Check: 53·67 mod 71 = 3551 mod 71 = 1
2.3.1: Compute divisor and modulus. 344 div 5
68 344 = 68·5 + 4, so 344 div 5 = 68.
2.12.1: Multiplicative inverses mod n ? * 8 mod 11 = 1
7 7 · 8 mod 11 = 56 mod 11 = 1
2.16.3: Number of digits base b How many digits are required to express the base 8 expansion of 8⁷ - 1?
7 n = 8⁷ - 1 and b = 8. The base 8 expansion of 8⁷ - 1 is (7777777)₈.
2.18.1: An illustration of fast integer exponentiation Compute 7¹¹
7⁸ * 7² * 7¹ 3210 Binary expansion of 11 = (1011)₂ 7^[(1 * 2³) + (0 * 2²) + (1 * 2¹) + (1 * 2⁰)] X
2.5.3: Computing arithmetic expressions modulo n. (651²³ + 17) mod 10
8 651 mod 10 = 1. Therefore, (651²³ + 17) mod 10 = (1²³ + 17) mod 10 = (1 + 17) mod 10 = 8
2.9.1: Brute force factoring Suppose that the slightly better brute force algorithm for factoring is given the number 653117 as input. How many numbers would the algorithm have to check to either find a factor or determine that the input is prime? (653117 happens to be a prime number).
807 The algorithm can stop checking numbers when it reaches x=⌊653117⌋=808. Since 653117 is prime, the algorithm will not find a factor before reaching x = 808. There are 807 numbers in the range 2 through 808 that are checked by the algorithm.
2.5.2: Congruence modulo n Group the numbers from the given set into classes of congruence. That is, put two numbers in the same group if they are equivalent modulo 11. {−57, 17, 108, 0, −110, −93, 1111, 130, 232}
Congruent to 0 modulo 11: 0, -110, 1111 Congruent to 1 modulo 11: 232 Congruent to 6 modulo 11: 17, -93 Congruent to 9 modulo 11: -57, 108, 130
2.5.2: Congruence modulo n Group the numbers from the given set into classes of congruence. That is, put two numbers in the same group if they are equivalent modulo 13. {−63, -54, -41, 11, 13, 76, 80, 130, 132, 137}
Congruent to 0 modulo 13: 13, 130 Congruent to 2 modulo 13: -63, 80, 132 Congruent to 7 modulo 13: 137 Congruent to 11 modulo 13: -54, -41, 11, 7
2.11.1: Applying the Euclidean Algorithm and the Extended Euclidean Algorithm Find the GCD of the two numbers, and express the GCD as a linear combination of the two numbers. 56 and 42
GCD(56, 42) = 14 = 56 - 42 56 42 14 0 56 mod 42 = 14 42 mod 14 = 0 GCD(56, 42) = 14 The equation is: 14 = 56 - (56 div 42)·42 = 56 - 42 GCD(56, 42) = 14 = 56 - 42
2.11.1: The Extended Euclidean Algorithm Write GCD of 675 and 210 as a linear combination of those two numbers
GCD(675, 210) = 15 = 5 * 675 - 16 * 210
2.11.1: Applying the Euclidean Algorithm and the Extended Euclidean Algorithm Find the GCD of the two numbers, and express the GCD as a linear combination of the two numbers. 81 and 60
GCD(81, 60) = 3 = 3·81 - 4·60 81 60 21 18 3 0 81 mod 60 = 21 60 mod 21 = 18 21 mod 18 = 3 18 mod 3 = 0 The equations for substitution are: 3 = 21 - (21 div 18)18 = 21 -18 18 = 60 - (60 div 21)21 = 60 - 2·21 21 = 81 - (81 div 60)60 = 81 - 60 Substitute (60 - 2·21) for 18 into the equation 3 = 21 -18 3 = 21 - (60 - 2·21) = 3·21 - 60 Substitute (81 - 60) for 21 into the equation 3 = 3·21 - 60 3 = 3·(81 - 60) - 60 = 3·81 - 4·60 GCD(81, 60) = 3 = 3·81 - 4·60
2.18.3: An execution of the iterative algorithm for fast exponentiation Consider the algorithm for iterative fast exponentiation on input x = 3 and y = 13 The loop executes 4 times on input y = 13. Which best describes the state of the algorithm at the beginning of each iteration of the loop?
Iteration 1: (r mod 2) = 1 Iteration 2: (r mod 2) = 0 Iteration 3: (r mod 2) = 1 Iteration 4: (r mod 2) = 1 The value of (r mod 2) in each iteration are the bits in the binary representation of y in reverse order.
2.18.3: An execution of the iterative algorithm for fast exponentiation Consider the algorithm for iterative fast exponentiation on input x = 3 and y = 13 The loop executes 4 times on input y = 13. Which best describes the state of the algorithm at the beginning of each iteration of the loop?
Iteration 1: s = x Iteration 2: s = x² Iteration 3: s = x⁴ Iteration 4: s = x⁸ The variable s is squared in each iteration, so if s is a power of x, the exponent doubles each iteration.
2.16.3: Number of digits base b How many digits are required to express the base 7 expansion of 2401?
Log₇ 2402 n = 2401 and b = 7. n + 1
2.18.2: Expressing exponents as products of terms whose exponents are powers of 2 The binary representation of 18 is 10010. Which expression is equivalent to b^18?
b^2^4 * b^2^1 18 = 1·2⁴ + 0·2³ + 0·2² + 1·2¹ + 0·2₀ = 2⁴ + 2¹
2.18.2: Expressing exponents as products of terms whose exponents are powers of 2 The binary representation of 25 is 11001. Which expression is equivalent to b^25?
b^2^4 * b^2^3 * b^2^0 25 = 1·2⁴ + 1·2³ + 0·2² + 0·2¹ + 1·20 = 2⁴ + 2³ + 2⁰
2.18.1: Expressing exponents as a product of terms whose exponents are powers of 2 For each value of y, express by as a product of terms of the form b^2^j, where j is a non-negative integer. y = 66
b^2^6 * b^2^1 66 = (1000010)₂ 66 = 2⁶ + 2¹
2.18.1: Expressing exponents as a product of terms whose exponents are powers of 2 For each value of y, express by as a product of terms of the form b^2^j, where j is a non-negative integer. y = 53
b⁵³ = b^2^5 * b^2^4 * b+2^2 * b^2^0 53 = (110101)₂ 53 = 2⁵ + 2⁴ + 2² + 2⁰
2.16.3: Number of digits base b How many digits are required to express the base 8 expansion of 9?
log₈ 10 n = 9 and b = 8. n + 1
2.18.3: An execution of the iterative algorithm for fast exponentiation Consider the algorithm for iterative fast exponentiation on input x = 3 and y = 13 What is the value of the output p at the end of the algorithm?
x * x⁴ * x⁸ The initial value for the variable is p = 1. p is multiplied by the current value of s in each iteration in which (r mod 2) = 1. (r mod 2) = 1 during iterations 1, 3, and 4. Therefore the output is x · x⁴ · x⁸.