Download CS271 Homework 3 Solution

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Approximations of π wikipedia , lookup

Collatz conjecture wikipedia , lookup

List of prime numbers wikipedia , lookup

Proofs of Fermat's little theorem wikipedia , lookup

Addition wikipedia , lookup

Elementary mathematics wikipedia , lookup

Quadratic reciprocity wikipedia , lookup

Arithmetic wikipedia , lookup

Positional notation wikipedia , lookup

Elementary arithmetic wikipedia , lookup

Mathematics of radio engineering wikipedia , lookup

Factorization of polynomials over finite fields wikipedia , lookup

Location arithmetic wikipedia , lookup

Transcript
CS271 Homework 3 Solution
4-1-20
In each case we just apply the division algorithm (carry out the division) to obtain the quotient and remainder, as in elementary school. However, if the dividend is negative, we must make sure to make the remainder
positive, which may involve a quotient 1 less than might be expected.
a) Since −17 = 2 · (−9) + 1, the remainder is 1. That is, −17 mod 2 = 1. Note that we do not write
−17 = 2 · (−8) − 1, so −17 mod 2 6= −1.
b) Since 144 = 7 · 20 + 4, the remainder is 4. That is, 144 mod 7 = 4.
c) Since −101 = 13 · (−8) + 3, the remainder is 3. That is, −101 mod 13 = 3. Note that we do not write
−101 = 13 · (−7) − 10; we cannot have −101 mod 13 = −10, because a mod b is always nonnegative.
d) Since 199 = 19 · 10 + 9, the remainder is 9. That is, 199 mod 19 = 9.
4-2-2
To convert from decimal to binary, we successively divide by 2. We write down the remainders so obtained
from right to left; that is the binary representation of the given number.
a) Since 321/2 is 160 with a remainder of 1, the rightmost digit is 1. Then since 160/2 is 80 with a remainder
of 0, the second digit from the right is 0. We continue in this manner, obtaining successive quotients of 40,
20, 10, 5, 2, 1, and 0, and remainders of 0, 0, 0, 0, 1, 0, and 1. Putting all these remainders in order from
right to left we obtain (1 0100 0001)2 as the binary representation. We could, as a check, expand this binary
numeral: 20 + 26 + 28 = 1 + 64 + 256 = 321.
b) We could carry out the same process as in part (a). Alternatively, we might notice that 1023 = 1024−1 =
210 −1. Therefore the binary representation is 1 less than (100 0000 0000)2 , which is clearly (11 1111 1111)2 .
c) If we carry out the divisions by 2, the quotients are 50316, 25158, 12579, 6289, 3144, 1572, 786, 393, 196,
98, 49, 24, 12, 6, 3, 1, and 0, with remainders of 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, and 1. Putting the
remainders in order from right to left we have (1 1000 1001 0001 1000)2 .
4-2-12
Following Example 7, we simply write the hexadecimal equivalents of each group of four binary digits.
Note that we group from the right, so the left-most group, which is just 1, becomes 0001. Thus we have
(0001 1000 0110 0011)2 = (1863)16 .
4-3-4
We obtain the answers by trial division. The factorizations are 39 = 3 · 13, 81 = 34 , 101 = 101 (prime),
143 = 11 · 13, 289 = 172 , and 899 = 29 · 31.
1
4-3-18
a) Since 6 = 1 + 2 + 3, and these three summands are the only proper divisors of 6, we conclude that 6 is
perfect. Similarly 28 = 1 + 2 + 4 + 7 + 14.
4-3-24
We form the greatest common divisors by finding the minimum exponent for each prime factor.
a) 22 · 33 · 52
b) 2 · 3 · 11
c) 17
d) 1
e) 5
f) 2 · 3 · 5 · 7
4-3-26
We form the least common multiples by finding the maximum exponent for each prime factor.
a) 25 · 33 · 55
b) 211 · 39 · 5 · 7 · 11 · 13 · 1714
c) 1717
d) 22 · 53 · 7 · 13
e) undefined (0 is not a positive integer)
f) 2 · 3 · 5 · 7
4-3-30
We know that the product of the greatest common divisor and the least common multiple of two numbers
is the product of the two numbers. Therefore the answer is (27 · 38 · 52 · 711 )/(23 · 34 · 5) = 24 · 34 · 5 · 711 .
4-3-32
To apply the Euclidean algorithm, we divide the larger number by the smaller, replace the larger by the
smaller and the smaller by the remainder of this division, and repeat this process until the remainder is 0.
At that point, the smaller number is the greatest common divisor.
a) gcd(1, 5) = gcd(1, 0) = 1
b) gcd(100, 101) = 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, 278) = gcd(278, 139) = gcd(139, 0) = 139
e) gcd(1529, 14038) = gcd(1529, 277) = gcd(277, 144) = gcd(144, 133) = gcd(133, 11) = gcd(11, 1) = gcd(1,
0) = 1
f ) gcd(11111, 111111) = gcd(11111, 1) = gcd(1, 0) = 1
4-6-4
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
2
c) EAT DIM SUM
4-6-8
Because of the word JVVU we guess that the ciphertext V might be the plaintext E or O. If it is the former,
then the shift would have to be 21 ? 4 = 17. Applying the inverse of that shift to the message yields MEN
LOVE TO WONDER, AND THAT IS THE SEED OF SCIENCE.
3