#set page(margin: (x: .5in, y: .5in)) #let solvein(solution) = { let outset = 3pt h(outset) box( outset: outset, stroke: blue + .3pt, fill: rgb(0, 149, 255, 15%), radius: 4pt, )[#solution] } #let solve(content) = [ #align( center, block( inset: 5pt, stroke: blue + .3pt, fill: rgb(0, 149, 255, 15%), radius: 4pt, )[#align(left)[#content]], ) ] #let notein(content) = { let outset = 3pt h(outset) box( outset: outset, stroke: luma(20%) + .3pt, fill: luma(95%), radius: 4pt, )[#content] } #let note(content) = [ #align( center, block( inset: 5pt, stroke: luma(20%) + .3pt, fill: luma(95%), radius: 4pt, )[#align(left)[#content]], ) ] #align(center)[ = CS 3333 Mathematical Foundations Homework 2 (100 points)\ #underline[Price Hiller] *|* #underline[zfp106] ] #line(length: 100%, stroke: .25pt) = Submission: Same as HW1. = Questions + Answer Yes or No (12 pts). #enum( numbering: "a.", [ Is $87 ≡ 51 (mod 5)$? #solvein[No] ], [ Is $34 ≡ 14 (mod 3)$? #solvein[No] ], [ Is $7 ≡ 55 (mod 24)$? #solvein[Yes] ], [ Is $29 ≡ 41 (mod 12)$? #solvein[Yes] ], ) + List 5 integers that are congruent to 6 modulo 19 (10 points). #solvein[ + $6$, #notein[$∵ (6 - 6) mod 19 = 0$] + $25$, #notein[$∵ (25 - 6) mod 19 = 0$] + $44$, #notein[$∵ (44 - 6) mod 19 = 0$] + $63$, #notein[$∵ (63 - 6) mod 19 = 0$] + $82$, #notein[$∵ (82 - 6) mod 19 = 0$] ] + Calculate the following problems (18 pts). #enum( numbering: "a.", [ $7+_(11) 34 =$ #solvein[$8$] #note[ + $(7 + 34) mod 11$ + $(41) mod 11$ + $8$ ] ], [ $5⋅_(13) 19 =$ #solvein[ $4$ ] #note[ + $(5 ⋅ 19) mod 13$ + $(95) mod 13$ + $4$ ] ], [ $17+_(11) 1 =$ #solvein[$7$] #note[ + $(17 + 1) mod 11$ + $(18) mod 11$ + $7$ ] ], [ $47+_(13) 0 =$ #solvein[$8$] #note[ + $(47 + 0) mod 13$ + $(47) mod 13$ + $8$ ] ], [ $55⋅_(11) 1 =$ #solvein[$0$] #note[ + $(55 ⋅ 1) mod 11$ + $(55) mod 11$ + $0$ ] ], [ $55⋅_(11) 0 =$ #solvein[$0$] #note[ + $(55 ⋅ 0) mod 11$ + $(0) mod 11$ + $0$ ] ], ) + Find all positive primes $<= 50$ (You can just list the positive prime numbers directly.) (10 points). #align(center)[ #solvein[ All primes $<= 50$ #table( columns: (auto, auto, auto, auto, auto), [2], [3], [5], [7], [11], [13], [17], [19], [23], [29], [31], [37], [41], [43], [47], )] #note[ Some Rust code to generate those primes :) ```rust fn main() { let is_prime = |num: usize| -> bool { num > 1 && !((2..num).any(|n| num % n == 0)) }; let primes: Vec<_> = (0..50).filter(|x| is_prime(*x)).collect(); println!( "Prime numbers: {:?}\nNumber of prime numbers found: {}", primes, primes.len() ); } ``` ] ] + Find all positive integers less than $50$ that are relatively prime to $50$ (showing the $\g\cd$ is optional. You can list all the numbers.) (10 pts). #align(center)[ #solvein[ All relative primes $< 50$ #table( columns: (auto, auto, auto, auto, auto), [2], [3], [5], [7], [ 11], [13], [17], [19], [23], [29], [31], [37], [41], [43], [47], )] #note[ Some Rust code to generate those co-primes :) ```rust fn gcd(a: &usize, b: &usize) -> usize { let mut a = *a; // Deref to avoid modifying the passed value let mut b = *b; // Deref to avoid modifying the passed value assert!(a != 0 && b != 0); while b != 0 { (a, b) = (b, a % b) } a } fn main() { let relative_primes: Vec<_> = (1..51).filter(|x| gcd(x, &50) == 1).collect(); println!( "Relatively prime numbers: {:?}\nNumber of relative prime numbers found: {}", relative_primes, relative_primes.len() ); } ``` ] ] + Express $\g\cd(990, 502) = 2$ as a linear combination of $990$ and $502$ by working backwards through the steps of the Euclidean algorithm (10pts). [Hint: refer to Example 17 in the textbook Section 4.3.8] #note[ Working it fowards: + $990 = 1 ⋅ 502 + 488$ + $502 = 1 ⋅ 488 + 14$ + $488 = 34 ⋅ 14 + 12$ + $14 = 1 ⋅ 12 + 2$ + $12 = 6 ⋅ 2 + 0$ + $\g\cd(990, 502) = 2$, from step $4$ Now backwards: + $2 = 14 - 1 ⋅ 12$ + $2 = 14 - 1 ⋅ (488 - 34 ⋅ 14)$ + $2 = -1 ⋅ 488 + 35 ⋅ 14$ + $2 = -1 ⋅ 488 + 35 ⋅ (502 - 488)$ + $2 = -36 ⋅ 488 + 35 ⋅ 502$ + $2 = -36 ⋅ (990 - 488) + 35 ⋅ 502$ + #solvein[$2 = - 36 ⋅ 990 + 71 ⋅ 502$] + #solvein[$2 = 71 ⋅ 502 - 36 ⋅ 990$] ] + Show that if $a ≡ b (mod m)$ and $c ≡ d (mod m)$, where $a$, $b$, $c$, $d$, and $m$, are integers with $m >= 2$, then $a - c ≡ b - d (mod m)$ (10 pts). #solve[ + $a ≡ b (mod m) = m | (a - b)$ + $a = b + m k$ where $k$ is an integer + $c ≡ d (mod m) = m | (c - d)$ + $c = d + m j$ where $j$ is an integer + $a - c = (b + m k) - (d + m j)$ + $a - c = (b - d) + (m k - m s)$ + $a - c = (b - d) + m(k - s)$ + $(a - c) - (b - d) = m (k - s)$ + $(a - c) - (b - d) = m i$, where $i = k - s$ is an integer + $m | (a - c) - (b - d)$ + $∴ a - c ≡ b - d (mod m)$ ] + Let $a$ and $b$ be positive integers. Then $a b = \g\cd(a, b) ⋅ \l\cm(a,b)$. #enum( numbering: "a.", [ Please prove it and show the intermediate steps (15 pts). [Hint: Use the prime factorizations of $a$ and $b$ and the formulae for $\g\cd(a, b)$ and $\l\cm(a, b)$ in terms of these factorizations. You also can use any other methods.] #solve[ + $a = p^(a_1)_(1) ⋅ p^(a_2)_(2) ⋅⋅⋅ p^(a_n)_(n)$, where $p_n$ are prime numbers and $a_n$ are non-negative integers + $b = p^(b_1)_(1) ⋅ p^(b_2)_(2) ⋅⋅⋅ p^(b_n)_(n)$, where $p_n$ are prime numbers and $b_n$ are non-negative integers + $\g\cd( a, b ) = p^(min(a_1,b_1))_1 ⋅ p^(min(a_2,b_2))_2 ⋅⋅⋅ p^(min(a_n,b_n))_n$ + $\l\cm( a, b ) = p^(max(a_1,b_1))_1 ⋅ p^(max(a_2,b_2))_2 ⋅⋅⋅ p^(max(a_n,b_n))_n$ + $g\c\d(a,b) ⋅ \l\cm(a, b) = ( p^(min(a_1,b_1))_1 ⋅ p^(min(a_2,b_2))_2 ⋅⋅⋅ p^(min(a_n,b_n))_n ) ⋅ ( p^(max(a_1,b_1))_1 ⋅ p^(max(a_2,b_2))_2 ⋅⋅⋅ p^(max(a_n,b_n))_n )$ + $g\c\d(a,b) ⋅ \l\cm(a, b) = ( p^(min(a_1,b_1) + max(a_1,b_1))_1 ⋅ p^(min(a_2,b_2) + max(a_2,b_2))_2 ⋅⋅⋅ p^(min(a_n,b_n) + max(a_n,b_n))_n )$ + $min(a_n,b_n) + max(a_n,b_n) = a_n + b_n$ + $g\c\d(a,b) ⋅ \l\cm( a,b ) = p^(a_1 + b_1)_1 ⋅ p^(a_2 + b_2)_2 ⋅⋅⋅ p^(a_n + b_n)_n = a b$ + $∴ a b = g\c\d(a,b) ⋅ \l\cm(a,b)$ #note[If I have to type another `p^(min(a_n,b_n) + max(a_n,b_n))_n`, I _will_ ask for #text(red)[ Ǵ̶̱̝̅̓ȯ̸͙̯͝d̵̛͇͓ͅ'̵̺̑̀͆ͅͅs̶̖̏ ̶̫͔̲͂m̶̱̗̤͒́̏a̵̛̝̳̒n̶̼̱̆ä̷̤ǧ̸̢͜͜e̶̡͂r̵̞̯̺̄].] ] ], [ Verify that $\g\cd(860, 516)⋅\l\cm(860,516) = 860 * 516$ (5 pts). #note[ + $860=2^2 ⋅ 3^0 ⋅ 5^1 ⋅ 43^1$ + $516=2^2 ⋅ 3^1 ⋅ 5^0 ⋅ 43^1$ #underline[GCD] + $\g\cd( 860, 516 ) = 2^(min(2,2)) ⋅ 3^(min(0,1)) ⋅ 5^(min(1,0)) ⋅ 43^(min(1,1))$ + $\g\cd(860, 516) = 2^2 ⋅ 3^0 ⋅ 5^0 ⋅ 43^1$ + $\g\cd(860, 516) = 4 ⋅ 1 ⋅ 1 ⋅ 43$ + $\g\cd(860, 516) = 172$ #underline[LCM] + $\l\cm( 860, 516 ) = 2^(max(2,2)) ⋅ 3^(max(0,1)) ⋅ 5^(max(1,0)) ⋅ 43^(max(1,1))$ + $\l\cm(860, 516) = 2^2 ⋅ 3^1 ⋅ 5^1 ⋅ 43^1$ + $\l\cm(860, 516) = 4 ⋅ 3 ⋅ 5 ⋅ 43$ + $\l\cm(860, 516) = 2580$ #underline[Check if gcd \* lcm = 860 \* 516] + $172 * 2580 = 443760$ + $860 * 516 = 443760$ + #solvein[$(172 ⋅ 2580 = 443760) = (443760 = 860 ⋅ 516)$] ] ], )