This preview shows pages 1–6. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 70 Chapter 3 ' The Fundamentals: Algorithms, the Integers, and Matrices 22. From a E b (mod m) we know that b = a+sm for some integer s. Multiplying by c we have be 2 (“3+ some), which means that no E be (mod mo) . I sue; . '24. write in = 2k + 1 for someinteger h. Then 712 = (2k + 1)2 = 4132 + 41: + 1 : 4k(k —— 1) + 1. Since either It or:
k: + 1 is even, 41:04: + 1) is a multiple of 8. Therefore an? — 1 is a multiple of 8, so 77,2 E 1 (mod 8). 26.32111 each case we need to compute k: mod 101 by dividing by 101 and ﬁnding the remainders. This can be /done with a calculator that keeps 13 digits 'of accuracy internally. Just divide the number by 101, subtract :2 off the integer part of the answer, and multiply the fraction that remains by 101. The result will be almost ;'
exactly an integer, and that integer is the answer.   a) 58 b) 60 c) 52 (1)3 28. We just calculate using the formula. We are given 3:0 = 3. Then x1 = (4  3 + 1) mod 7 = 13 mod 7 = 6;;
3:2 = (46+ 1) mod 7 = 25 mod 7 = 4; $3 : (44l— 1) mod 7 =17 mod 7 = 3. At this point the sequence
must continue to repeat 3, 6, 4, 3, 6, 4, forever. I 30. We assume that the input to this procedure consists of a modulus (m 2 2), a multiplier (:31), an increment
(c), a seed (m0), and the number of pseudorandom numbers desired. The output will be the sequence {931a}. procedure pseudomndom(m, a, c, :30, n. : nonnegative integers)
for i := 1 to n
:0, := (a512,_1 + 0) mod m x. _ 32. We just need to “subtract 3” from each letter. For example, E goes down to B, and B goes down to Y. a) BLUE JEANS b) TEST TODAY (3) EAT DIM SUM 34.. We know that 10+2.3+32+41+52+63+7Q+80+97+10*2 E 0(m0d11)1Thisf
simpliﬁes to 127 + 762 E 0 (mod 11) .' We subtract 127 from both sides and simplify to 7Q E 5 (mod 11),
since —127 2: ——12  11 + 5. It is now a simple matter to use trial and error (or the methods to be introduced in Section 3.7) to ﬁnd that Q = 7 (since 49 E 5 (mod 11) SECTION 3.5 Primes and Greatest Common Divisors 2. The numbers 19, 101, 107, and 113 are prime, as we can verify by trial division. The numbers 27 = 33 an.
93 = 3 r 31 are not prime. 4. We obtain the answers by trialrdivision. The factorizations are 39 = 3  13, 81 = 34, 101 = 101 (prime)
143:1113, 289:172,and 89922931. ' 6. A 0 appears at the end of a number for every factor of 10 (= 2  5) the number has. New 100! certainly h;
more factors of 2 than it has factors of 5, so the number of factors of 10 it has is the same as the number I?
factors of 5. Each of the twenty numbers 5, 10, 15, ..., 100 contributes a factor of 5 to 100! , and in additio
the four numbers 25, 50, 75, and 100 contribute one more factor of 5. Therefore there are 24 factors of f
in 100!, so 100! ends in exactly 24 0’3. I (me follow the hint. There are n numbers in the sequence (7?. + 1)! + 2, (n + 1)! + 3, (n + 1)! + 4, + 1)! + (n + 1). The ﬁrst of these is composite because it is divisible by 2; the second is composite beca it is divisible by 3; the third is composite because it is divisible by 4; . . .; the last is composite because it '
divisible by n + 1. This gives us the desired 7?. consecutive composite integers. Section 3.5 Primes and Greatest Common Divisors st common divisors of the numbers from 1 to 10. We must ﬁnd, by inspection with mental arithmetic, the greats
and 11. There are so few since 12 had many or  12 Since these numbers are small, the eas1est approach 1s to ﬁnd the prlme factorization of each number and look for any common prime factors  tie a) $111.33 21 :. 3 7, 34 = 2 17, and 55 = 5  11, these are pa1rw1se relatively prime ' t b) Since 85 = 5 17, these are not pairvv1se relatively prime   *“' c) Since 25 = 52 , 41 is prime, 49 = 72, and 64 = 26 these are pairwise relatively prime 1(2p — 1). Certainly allthe numbers 1, 2, 4, 8, ,__, 211—1 are proper divisors, and their sum is 28 — 1 (this is a geometric series). Also each of these divisors times _, , 2p — 1 is also adivisor, and all but the last is proper. Again adding up this geometric series we ﬁnd a sum
" of (2? — 1X28"1 — 1). There are no other other proper divisors. Therefore the sum of all the divisors is
(21” — 1) + (2p — 1)(2f"‘1 — 1)’ = (21’ — 1)(1 + 21”—1 —— 1) = (233 — 1)2p"1, which is our original number. Therefore b) We need to ﬁnd all the proper divisors of 2P"— this number is perfect. 16. We need to ﬁnd a factor if there is one, or else check all possible prime divisors up to the square root of the given number to verify that there is no nontrivial divisor. ..
r . hese are not factors. Since V127 < 13, we are "if. _ a) 27 — 1 = 127. Division by 2, 3, 5, 7, and 11 shows that t done; 127 is prime. ' _ b) 29 — 1 = 511 = 7  73, so this number is not prime.
I'Is .3, J I c) 211 — 1 = 2047 = 23  89, so this number is not prime. 1, (1)213 1 = 8191. Division by 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
ﬁ' 73, 79, 83, and 89 (phew!) shows that these are not factors. Since < 97, we are done; 8191 is prime. Certainly if n is prime, then all the integers from 1 to n — 1 are less than or equal to n and relatively prime
5., to it, but no others are, so Mn) = n — 1. Conversely, suppose that n is not prlme If n = 1, then we have
i (M1) = 1 54 1 — 1 If n > 1, then 71. == ob w1th 1 < o. < n and 1 < b < 71. Note that neither (1 nor 5 is
d relatlvely prime to n. Therefore the number of poSItive integers less than or equal to n, and relatively prime  to n is at most as  3 (smce o, b, and n are not in th1s collection), so (0(a) aé n — 1 We form the greatest common d1v1sors by ﬁnding the mlmmum exponent for each prime factor f} 1'25: a) 22 33 52 b) 2 3 11 c) 17 d) 1 e) 5 f) 2 3 5 7 We form the least common multiples by ﬁnding the max1mum exponent for each prime factor ,1 , .._ a) 25 33 55 b) 211 39 5 7 11  13  171*1 c) 1717 d) :22 53 7 13 5 , e) undeﬁned (0 is not a pos1t1ve integer) f) 2 3 5 7 4. We have 1000 = 23  53 and 625 = 54, SO 8011(10001625) : 53 = 125i and 1011100001625) = 23 ' 54 = 5000 AS expected, 125 5000 = 625000 = 1000  625. ..  By Exercise 27 we know that the product of the greatest common divisor and the least common multiple of two (27_38,52,711)/(23_34_5):24_34,5 711 numbers is the product of the two numbers. Therefore the answer is I.
j _ how many m
below, we could simply program), and thereby 0b . _;I  r
.r _ . .w  {he Igl"! integers and Algorithms 73 fiflmction f as suggested from the positive—rational numbers to the positive integers. This is a one— rrlme factorm 92 + 1)  (e 5 ion, because if we are given the value of f (p/ q) , we can immediately recover p and q uniquely
tor we can q) in base eleven and noting what appears to the left of the one and only A in the expansion the right (and interpret these as numerals in base ten). Thus we have a oneto—one of positive rational numbers and an inﬁnite subset of the natural numbers, between the set
imtable; therefore the set of positive rational numbers is countable. T". 1‘ “tended here) Integers and Algorithms
.. + 1 =  . . .
2;? 4 ) _'*froin decimal to binary, we successively divide by 2. We wrlte down the remamders so obtamed
I 2;) with _: left; that is the binary representation of the given number. = 1 or . . . . . . .. .. .. ..
l 6 pectw is 160 w1th a remamder of 1, the r1ghtmost d1g1t 1s 1. Then smce 160/2 1s 80 W1th a remamder
: res * r digit from the right is 0. We continue in this manner, obtaining successive quotients of 40, 1, and 0, and remainders of 0, 0, 0, 0, 1, 0, and 1. Putting all these remainders in order
. left we obtain (1 0100 0001)2 as the binary representation. We could, as a check, expand this 20 + 26 + 28 = 1 + 64 + 256 = 321. I
d 22. ' out the same process as in part (a). Alternatively, we might notice that 1023 = 1024 — 1 :
_:_32 an '."re the binary representation is 1 less than (100 0000 0000)2, which is clearly (11 1111 1111)2. 1‘1' .6111; the divisions by 2, the quotients are 50316, 25158, 12579, 6289, 3144, 1572, 786, 393, "' 12, 6, 3, 1, and 0, with remainders of 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0a 0, 1, and
I iremainders in order from right to left we have (1 1000 1001 0001 1000)2. . F _'.' a Vii1"...— ~ 512 and 24 " = 27 b) 1 + 4 + 16 + 32 + 128 + 512 = 693
, 517916 + 32 + 128 + 256 + 512 = 958 " +16 +1024 + 2048 + 4096 + 8192 + 16334 = 31775 6, we simply write the'binary equivalents of each digit. Since (Aha = (1010)2, (B)16 = (D)15 1: , (E)15 = and (F)15 = we have 111111010110011101101)2. Following the convention shown in Exercise 3 of grouping binary :1 of the 5613111611; . __
' ' "'2...~"can write this in a more readable form as 1011 1010 1101 1111 1010 1100 1110 1101. .lr  hr: £113: ‘
.1; ' .‘8
. .{ 2.1 . . bathed stated in Example 6.
.553: F7 b) 1010 1010 1010 becomes AAA 0) 111 0111 0111 0111 becomes 7777 1 from the right, so the leftmost group, which is just 1, becomes 0001. Thus we have r: ._ Ei _. l ‘
1,166, we simply write the hexadecimal equivalents of each group of four binary digits. = (1863)15. 3! be the hexadecimal expansion of a positive integer. The value of that integer is, therefore, 162 + : hg + I11 * 2“1 + hg r 28 + If we replace each hexadecimal digit h,— by (b,3b,gb,1b,g)2, then h, = 13,0 — 23231 + 411,2 +‘8b,3. Therefore the value of the entire I + 4b62 + 8b03 + (blﬂ + 21211  11512 + 8513) ' 24  (520 + 21321 + 4522 + 8523) ' 28 + *  ' = 24010 + 25011 + 26012 + 27013 + 28020 + 29021 + 210022 + 211023 +  * , WhiCh 18 the I expansion   523522 521 526 513 512 51 1 b1!) 563 562 561 566 ) 2  I_I. LI
1" rail .
11211;; I... ;_ same as what we can do with hexadecimal expansion, replacing groups of four with groups y, convert each octal digit into its 3—digit binary equivalent. For example, (306)8 = Jul
J; rrr ,. . '1.
. __.—a,__==. _ '74 Chapter 3 The Fundamentals: Algorithms, the Integers, and Mat 16. Since we have procedures for convertingboth octal and hexadecimal to and from binary (Example 6 .5
Exercises 13—15), to convert from hexadecimal to octal, we ﬁrst convert from hexadecimal to binary and convert from binary to octal. 18.. We work through binary in each case; see Exercises 16 and 17. Thus (12345070)8 = (001 010 011 100 101 110 111 000)2 = (0010 1001 1100 1011 1011 1000)2 = (200033),,, and
(ABB093BABBA)15 :2 (1010 1011 1011 0000 1001 0011 .1011 1010 1011 1011 1010)2 = (010 101 011 101 100 001 001 001 110 111 010 101 110 111 010),?
= (253541110725072), .—' “a.
.I'
.I'
. f 20. ;In effect, this algorithm computes .11 mod 645, 112 mod 645, 114 mod 645, 118 mod 645, 1
" . . . , and then multiplies (modulo 645) the required values. Since 644 = (1010000100)2, we need to mult':
together 114 mod 645, 11128 mod 645, and 11512 mod 645, reducing modulo 645 at each step. We corn by repeatedly squaring: 112 mod 645 = 121, 11‘1 mod 645 = 1212 mod 645 = 14641 mod 645 1!: 118 mod 045 = 41512 mod 045 = 203401 mod 045 = 220, 1116 mod 045 = 2202 mod 045 = 51070 mod 0? 121. At this point we notice that 121 appeared earlier in our calculation, so we have 1132 mod 64 1212 mod 645 = 451, 1164 mod 645 = 4512 mod 645 = 226, 11128 mod 645 = 2262 mod 645 = 11256 mod 645 = 451, and 11512 mod 645 = 226. Thus our ﬁnal answer will be the product of 451, 121,: 226, reduced modulo 645. We compute these one at a time: 451  121 mod 645 = 54571 mod 645 = 391,} 391 i 226 mod 645 = 88366 mod 645 = 1. So 11644 mod 645 = 1. A computer algebra system will 1 this; use the command “1 35" 644 mod 645;” in Maple, for example. The ampersand here tells Maple to;
i ' ' 1644 . 116 mod j; 22. In effect this algorithm computes powers 123 mod 101, 1232 mod 101, 1234 mod 101, 1238 mod,
12316 mod 101, ..., and then multiplies (modulo 101) the required values. Since 1001 = (1111101001)?
need to multiply together 123 mod 101, 1238 mod 101, 12332 mod 101, 1236:1 mod 101, 123128 modf
123256 mod 101, and 123512 mod 101, reducing modulo 101 at each step. We compute by repea.
squaring: 123 mod 101 = 22, 1232 mod 101 = 222 mod 101 = 434 mod 101 = 30, 1234 mod :
302 mod 101 = 0400 mod 101 = 37, 1238 mod 101 = 372 mod 101 = 1300 mod 101 = 50, 12316 mod 1'
502 mod 101 = 3130 mod 101 = 5, 12332 mod 101 = 52 mod 101 = 25, 12354 mod 101 = 252 mod 025 mod 101 = 19, 123128 mod 101 = 192 mod 101 = 301 mod 101 = 53, 123256 mod 101 = 5s2 medr
= 31: and 123512 mod 101 z 312 mod 101 = 961 mod 101 = 52. Thus our ﬁnal anew; be the product of 22, 56, 25, 19, 58, 31 and 52. We compute these one at a time modulo 101: 22 a 24. To apply the Euclidean algorithm, we divide the larger number by the smaller, replace the larger by the a}.
I r the remainder of this division, and repeat this process until the remainder is 0. Ike.5 'd___." point, the smaller number is the greatest common divisor.
a) gcd(1,5) = gcd(1,0) = 1 b) gcd(100,101) 2‘ gcd(100, 1) = gcd(1,0) = 1 c) gcd(123,277) = gcd(123,31) = gcd(31,30) = gcd(30, 1) = gcd(1,0) = 1 _ :
d) gcd(1529,14039) = gcd(1529, 273) = gcd(278,139) = gcd(139, 0) = 139 _;
( e) gcd 1529,14038) 2; gcd(1529, 277) = gcd(277, 144) = gcd(144, 133) : gcd(133,11) = gcd(11,1) .= 3,3
:: 1 I; 431311063 9' _: 3.6 Integers and Algorithms ._ . 75 .,. 1, 6 and " to divide successively by 55, 34, 21, 13, 8, 5, 3, 2, and 1, so 9 divisions are required.
a l 1 _ =9 —' 3 — 1 b) 13 = 9 + 3 + 1 ' c) 37 = 27 + 9 + 1 d) 79 = 81 — 3 + 1 _I_ J. . I
Hg: ,— ' key fact here is that 10 E —1 (mod 11) , and so 10"c E (—1)k (mod 11). Thus 10"“ is congruent to 1 if k is 916' and to —1 if k is odd. Let the decimal expansion of the integer n be given by (o,,_1o,,__2 . . . o3n2a1o0)10. a = 10”"1n,,_1 + 10”"2o,,_2 + l— 10:11 + 00. Since 10’“ _=_ (——1)"‘ (mod 11), we have a E ion_1 q: +   — a3 + o2 — 0,1 —l— :10 (mod 11), where signs alternate and depend on the parity of 71. Therefore
.. (mOd 11) if and only if ((10 + 652 + :34 +    (£11  033 + (.15 +   ), which we obtain by collecting the. and even indexed terms, is congruent to 0 (mod 11). Since being divisible by 11 is the same as being
'_Jngruent to 0 (mod 11), we have proved that a positive integer is divisible by 11 if and only if the sum of
d 645 j :iitlecimal digits in evennumbered positions minus the sum of its decimal digits in oddnumbered positions
ultiply _j;_divisible by 11.
mpute E = 451, I gSince the binary representation of 22 is 10110, the six bit one’s complement representation is 010110.
545 E I. "1;Since the binary representation of 31 is 11111, the six bit one’s complement representation is 011111.
645 = g IiiSince the binary representation of 7 is 111, we complement 000111 to obtain 111000 as the one’s comple—
= 121: f representation of —7 ..
1, and g: Since the binary representation of 19 is 10011, we complement 010011 to obtain 101100 as the one’s
1* and I plement representation of — 19.
verify I; '
to use _ .
hough. 1 IS changed to a 0, and every 0 rs changed to a 1.
avoids  "if: just combine the two ideas in Exercises 34 and 35: to form a. ~— 0, we compute a + (—0), using Exercise 34 —b and Exercise 35 to ﬁnd the sum.
l 101, _
)2! We ? ' owing the deﬁnition, we ﬁnd the two“s complement expansion of a positive number simply by representing it
i 101 = u my, using six bits; and we ﬁnd the two’s complement expansion of a negative number —93 by representing
madly a: in binary using ﬁve bits and preceding it with a 1. ; {Since 22is positive, and its binary expansion is 10110, the answer is 010110..
101 I fines 31 is positive, and its binary expansion is 11111, the answer is 011111.
101 E —7 is negative, we ﬁrst ﬁnd the 5bit binary expansion of 25 — 7 = 25, namely 11001, and precede
Er will ._ a 1, obtaining 111001.
56 is ' —19 is negative, we ﬁrst ﬁnd the 5—bit binary expansion of 25 — 19 = 13, namely 01101, and precede
: 22_ by a 1, obtaining 101101.
“taller 6 can experiment a bit to ﬁnd a convenient algorithm. We saw in Exercise 38 that the expansion of —7
3 that '_.111001, while of course the expansion of 7 is 000111. Apparently to ﬁnd the expansion of —m from that m we complement each bit and then add 1, working in base 2. Similarly, the expansion of —8 is 111000,
nihereas the expansion of 8 is 001000; again 110111 + 1 '= 111000. At the extremes (using six bits) we have
{iirepresented by 000001, so 1 is represented by 111110 + 1 = 111111; and 31 is represented by 011111, so ,531 is represented by 100000 + 1 = 100001. '
.(1, 0.) . ' ' ‘ . just combine the two ideas in Exercises 40 and 41: to form a — b, we compute o + (—0), using Exercise 40
_.Iﬁnd ——b and Exercise 41 to ﬁnd the sum. ' ...
View Full
Document
 Spring '09

Click to edit the document details