102 hw 4

6
William Chen-wrc7 CompSci 102-Discrete Math Bruce Maggs 27 October 2010 HW 4 1. For i = 1 to n-1, let Y i = 1 if s i = H and s i+1 = H. Then X = Y 1 + …+ Y n-1 and for all i, E(Y i ) = ¼. Thus, E(X) = E(Y i ) + …+ E(Y n- 1 ) = (n-1)/4. 2. Using the above notations, note that when |i – j| > 1, the random variables Y i and Y j are independent. Therefore, we can define two random variables as follows: if n is even, let X 1 = Y 1 + Y 3 + …+ Y n-1 , and X 2 = Y 2 + Y 4 + …+ Y n-2 if n is odd, let X 1 = Y 1 + Y 3 + …+ Y n-2 , and X 2 = Y 2 + Y 4 + … + Y n-1 Now X = X 1 + X 2 , and each of X 1 and X 2 is a sum of independent random variables. 3. a) 321/2 = 160 R 1 160/2 = 80 R 0 80/2=40 R 0 40/2=20 R 0 20/2=10 R 0 10/2=5 R 0 5/2=2 R 1 2/2=1 R 0

Upload: william-chen

Post on 28-Mar-2015

13 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: 102 HW 4

William Chen-wrc7

CompSci 102-Discrete Math

Bruce Maggs

27 October 2010

HW 4

1. For i = 1 to n-1, let Yi = 1 if si = H and si+1 = H. Then X = Y1 + …+ Yn-1 and for all i, E(Yi) = ¼. Thus, E(X) = E(Yi) + …+ E(Yn-1) = (n-1)/4.

2. Using the above notations, note that when |i – j| > 1, the random variables Yi and Yj are independent. Therefore, we can define two random variables as follows:

if n is even, let X1 = Y1 + Y3 + …+ Yn-1, and X2 = Y2 + Y4 + …+ Yn-2

if n is odd, let X1 = Y1 + Y3 + …+ Yn-2, and X2 = Y2 + Y4 + …+ Yn-1

Now X = X1 + X2, and each of X1 and X2 is a sum of independent random variables.

3. a) 321/2 = 160 R 1

160/2 = 80 R 0

80/2=40 R 0

40/2=20 R 0

20/2=10 R 0

10/2=5 R 0

5/2=2 R 1

2/2=1 R 0

1/2=0 R 1

32110=1010000012

b)

R 1 1 1 1 1 1 1 1 1 11023 511 255 127 63 31 15 7 3 1102310=111111111l2

c)

Page 2: 102 HW 4

R 0 0 0 1 1 0 0 0 1 0 0 1 0 0 0 1 1100632 50316 25158 12579 6289 3144 1572 786 393 196 98 49 24 12 6 3 1

10063210=110001001000110002

4. By definition, ɸ(n) = the number of positive integers less than or equal to n that are relatively prime to n. (1) If n is a prime, then every positive integer less than n is relatively prime to n. Therefore, we must have ɸ(n) = n-1. (2) if n is not a prime, then there must be an integer m such that 1 < m < n and m divides n, i.e., m and n are not relatively prime. Therefore, we must have ɸ(n) < n-1.

5. Consider an integer X = (dndn−1 … d1d0)10 = dn•10n + dn−1•10n−1 + · · · + d1•10 + d0. For an even number h, write 10h as (99…99 + 1) (there are h 9’s), and for an odd number h, write 10h as (100…01 − 1) (there are h – 1 0’s between the two 1’s). For example, if n is even, then we write

X = dn•10n + dn−1•10n−1 + · · · + d1•10 + d0

= dn•(99…99 + 1) + dn−1•(10…01 – 1) + · · · + d1•(11- 1) + d0

= (dn•99…99 + dn−1•10…01 + · · · + d1•11) + (dn − dn−1+ … − d1 + d0 )

Note the 99…99 (with an even number of 9’s) is divisible by 11, and 10…01 (with an even number of 0’s between the two 1’s) is also divisible by 11. Thus, the first term of X (dn•99…99 + dn−1•10…01 + · · · + d1•11) is divisible by 11. Therefore, X is divisible by 11 if and only if its second term (dn − dn−1+ … − d1 + d0 ) is divisible by 11. Note that the second term (dn − dn−1+ … − d1 + d0 ) of X is equal to the difference of the sum of its even-numbered positions and the sum of its odd-numbered positions. This completes the proof for the case when n is even. The case when n is odd can be proved similarly.

6. If a|c, then a=kc, where k is an integer; also, by the givens, then b=md, where m is another integer. Thus a*b = k*m*c*d = kmcd. Thus, since k*m is simply another integer which we can call n, then we see ab=ncd, thus proving ab|cd.

7. Every multiple of 10 will add another zero, as well as every set of 2 and 5; thus all we have to do is count how many of these there are. There are 9 numbers with 1 zero (10-90) and 100 has 2 zeroes. Thus the multiples of ten sum to 11 zeroes. Furthermore, there are 10 pairs of twos and fives (2-5, 12-15, 22-25, 32-35..etc). Thus, there will be 21 zeroes in 100!.

8. a) 6 = 1+2+3, so 6 is perfect because 1, 2, and 3 are all the positive divisors of 6.

28 = 1+2+4+7+14, so 28 is perfect because 1, 2, 4, 7, 14 are all the positive divisors of 28.

b) If 2p – 1 is a prime, then all the positive divisors of 2p-1 (2p – 1) (not including 2p-1 (2p – 1) itself) are 1, 2, 22, …, 2p-1, and (2p – 1), 2*(2p – 1), 22*(2p – 1), …, (2p-2)*(2p – 1), Adding all these divisors, we get

(1+2+22+ …+2p-1)+(2p – 1)+ 2*(2p – 1)+22*(2p – 1)+ …+(2p-2)*(2p – 1)

= (2p -1) + (2p – 1)( 2p-1 – 1) = 2p-1 (2p – 1).

Page 3: 102 HW 4

Therefore, 2p-1 (2p – 1) is perfect.

9. A Mersenne prime is a prime which has the format 2n – 1 and is a true prime as well.

a) 27 - 1 = 127 (is Mersenne prime)

b) 29 - 1 = 511 = 7 * 73 α (is not prime)

c) 211 – 1 = 2047 = 23 * 89 α (is not prime)

d) 213 – 1= 8191 (is Mersenne prime)

αHelp from http://www.classbrain.com/artteach/publish/article_48.shtml

10. Let the primes that either divide a or divide b be p1, p2, …, pk, then the integers a and b can be uniquely written as a = p1

a1 • p2a2 • … • pk

ak and b = p1b1 • p2

b2 • … • pkbk , where a1, a2, …, ak,

b1, b2, …, bk are non-negative integers such that if pi is not a prime divisor of a, then ai = 0 (similar for bi). By definition,

gcd(a, b) = p1min(a1, b1) • p2

min(a2, b2) • … • pk min(ak, bk1) , and

lcm(a, b) = p1max(a1, b1) • p2

max(a2, b2) • … • pk max(ak, bk1) .

Therefore,

gcd(a, b) • lcm(a, b) = p1min(a1, b1)+max(a1,b1) • p2

min(a2, b2)+max(a2,b2) • … • pk min(ak, bk1)+(ak, bk)

= p1a1+b1 • p2

a2+b2 • … • pk ak+bk = (p1

a1 • p2a2 • … • pk

ak) • (p1b1 • p2

b2 • … • pkbk) = a•b

11. a)

a 5 1b 1 0GCD = 1

b)

a 101 100 1b 100 1 0GCD = 1

c)

a 277 123 31 30 1b 123 31 30 1 0GCD = 1

Page 4: 102 HW 4

d)

a 14039 1529 278 139b 1529 278 139 0GCD = 139

e)

a 14038 1529 277 144 133 11 1b 1529 277 144 133 11 1 0GCD = 1

f)

a 111111 11111 1b 11111 1 0GCD = 1

12.

a) Let x =

1

2+1

2+1

2+…

. Because of the recursion, we get x = 1

2+ x . Then just solve this

equation, which gives x = √2 – 1.

b) You can solve this similarly, and get x = (√13 – 3)/2.

13.

a) By definition, Fib(n+1) = Fib(n) + Fib(n-1), so Fib(n+1) mod Fib(n) = Fib(n-1). Thus, the Euclidean algorithm in the first step divides Fib(n+1) by Fib(n) to get Fib(n-1) then recursively computes gcd(Fib(n), Fib(n-1)). In general, in the j-th step, the algorithm divides Fib(n-j+2) by Fib(n-j+1) to get Fib(n-j) then recursively computes gcd(Fib(n-j+1), Fib(n-j)). Thus, in the (n-1)-th step, the algorithm the algorithm divides Fib(3) = 2 by Fib(2) = 1 to get 2 mod 1 = 0 so that algorithm stops. Therefore, the algorithm totally took n-1 divisions.

b). By the result in a), g(n) = n – 1. We prove b) for n ≥ 1 by induction on n.

For n = 1, if A > B and Euclid’s algorithm takes g(n) = g(1) = 1 – 1 = 0 divisions to compute gcd(A, B), then by the algorithm, we must have B = 0 . Since A > B, we must have A ≥ 1. This proves that when n = 1, we have A ≥ Fib(n+1) = Fib(2) = 1, and B ≥ Fib(n) = Fib(1) = 0.

Now we consider the general case n > 1. If A > B and Euclid’s algorithm takes g(n) = n – 1 divisions to compute gcd(A, B), then the first division is to divide A by B, then recursively we compute gcd(B, A mod B). Therefore, Euclid’s algorithm takes n – 2 = g(n-1) divisions to

Page 5: 102 HW 4

compute gcd(B, A mod B). By the inductive hypothesis and noting B > (A mod B), we have B ≥ Fib(n) and (A mod B) ≥ Fib(n-1). Since A > B, we must have A ≥ B + (A mod B). By the inequalities B ≥ Fib(n) and A mod B ≥ Fib(n-1), we get

A ≥ B + (A mod B) ≥ Fib(n) + Fib(n-1) = Fib(n+1).

Thus, in general case, we also have A ≥ Fib(n+1), and B ≥ Fib(n) .