COMPUTER PROBLEMS: DAY 3

advertisement

COMPUTER PROBLEMS:

DAY 3

(1) Compute the following expressions by using successive squaring. Do not use a Python program. (We will get to this later.) You may use Python to square or multiply numbers. You should write down your work. (It is easy to get lost otherwise.)

(a) 2 87634

(b) 437 2763

(c) 98 18573

(d) 9872

32 mod 101 mod 1041 mod 27 mod 81573

(2) Write a program that runs the fermat primality test without using successive squaring. Test it out for some primes and nonprimes.

(3) Use Jim Carlson’s code modpower to implement modular powers (i.e.

a n mod b ) by successive squaring. (If you wish, you can write your own successive squaring program instead.) For some very large powers, compare the time it takes modpower to compute exponentials to the time it takes Python to compute these without successive squaring. Mladen Bestvina’s notes discuss how to time operations in Python.

(4) Rewrite your Fermat test program using modpower . Compare the performance of the old and new test programs for very large numbers.

(5) Implement Euler’s φ -function in Python. You can either write your own code or use the code posted on the website. If you use the posted code, try to understand how it works. Measure how long it takes to compute φ for various large numbers.

(6) Write a chinese remainder theorem program. In particular, let a and b be relatively prime. Your program will request as input a , b , n mod a and n mod b . It will should then return n mod ab .

Non-computer problems:

(1) Prove that if n > 4 and n is not prime then ( n

(2) Compute x

13 +

1 in terms of a = x +

1

.

x 13 x

1)! is divisible by n .

1

Download