Solutions to other tests:
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  

Mathematics for the Digital Age
and
Programming in Python


>>> Second Edition

Test 17

1.
(a), (c), (d)
2.
February 7
3.
(a) T   (b) F   (c) T
4.
1043
5.
(b), (c)
6.
(a) T   (b) T   (c) F   (d) F
7.
(a) F   (b) F   (c) T
8.
D
9.
(b), (c)
10.
2
11.
3
12.
0
13.
(a) T   (b) T   (c) F
14.
(a) T   (b) T   (c) T
15.
(b), (c)
16.
2

33 = −1 (mod 7)
36 = 1 (mod 7)
3128 = 3(21*6+2)  =  (36)21 * 32 = 9 (mod 7)= 2 (mod 7).
17.
5
18.
key = rab = Kba = Kab.
19.
A
20.
(a) T   (b) F   (c) T

21.
481

111111 − 10 * 8177 = 29341
29341 − 3 * 8177 = 4810
8177 − 4810 = 3367
4810 − 3367 = 1443
3367 − 2 * 1443 = 481
1443 − 3 * 481 = 0
22.
73

Examining the sequence 7, 18, 29, 40, 51, 62, 73
and the sequence 5, 22, 39, 56, 73
we find they first overlap at 73.
23.
def isSingeFactor(n): for d in range(2, n): if n % (d * d) == 0: return False return True
24.
25.
The text of the question is encoded with a simple shift-by-one substitution cipher. It reads:
Write a function that takes a string in plain text and creates a code string replacing every letter in text with the next letter in the alphabet (‘Z’ should become ‘A’).  The function should preserve upper and lower case and leave punctuation and other non-alphabetic characters unchanged.
def encode(text): abc = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" key = "bcdefghijklmnopqrstuvwxyzaBCDEFGHIJKLMNOPQRSTUVWXYZA" code = "" for c in text: i = abc.find(c) if i >= 0: c = key[i] code += c return code
26.
(a)

47

57 mod 77 = (625 mod 77) * (125 mod 77) = (9 * 48) mod 77 = 432 mod 77 = 47.

(b)

53

p = 7; q = 11
(p − 1)(q − 1) = 60
D must satisfy the equation 77D − 60y = 1
17D − 60y2 = 1, where y2 = y − D
17x2 − 9y2 = 1, where x2 = D − 3y2
x2 = −1; y2 = −2
D = x2 + 3y2 = −7
We can add any multiple of 60 to D to make it positive: D = −7 + 60 = 53.



Copyright © 2010 by Skylight Publishing