COMPUTER PROBLEMS: DAY 3 (1) Compute 217946 mod 17947. Is 17947 prime? (2) The following program computes numbers u, v such that gcd(a, b) = ua + vb: def egcd(a,b): q,r = divmod(a,b) x,y,u,v=1,-q,0,1 while r>0: qq,rr = divmod(b,r) xx,yy=u-qq*x,v-qq*y a,b,r,q,x,y,u,v=b,r,rr,qq,xx,yy,x,y print a,b,r,q,x,y,u,v return u,v,b Try it out with a few numbers to convince yourself that it works. Can you explain how it works? (3) Use egcd to find the the inverses of 117 mod 103, 222 mod 17947 and 1234567 mod 1812647. (4) My date of birth was encoded using the function 1234567 ∗ x mod 1812647. If f (x) = 1201707, what is my date of birth x? (5) Write a program that computes the inverse of a mod b. Check that it works for 117 mod 103 and for 222 mod 17947. What happens for 123 mod 309? (6) If you have time, write a program that computes the order of 2 mod b (i.e. the smallest power t such that 2t = 1 mod b). 1