COMPUTER PROBLEMS DAY 6 HSP 2010

advertisement
COMPUTER PROBLEMS DAY 6
HSP 2010
(1) Do the following calculations without using a computer program. (You can use Python as a
calculator, but work through the steps of the successive squaring algorithm by hand.)
(a) 941052 mod 107
(b) 25368 mod 91
(c) 173000 mod 113
(d) 12256 mod 291
(2) Compute 14313542543656451431354254365645 mod 7987987908098. You will need to write a
Python function that computes modular powers by successive squaring. (What happens
when you try the computation directly in Python?) You should get 7159097467039.
(3) Write a Python program that checks the primality of numbers by using Fermat’s little theorem. Check if 89809099, 75307568412715349903, 19605263919318560687 and
49349822528981278234665901647294396081213664101046
86716378205258797050794163803176579697937348881157
are prime. Can you factor the ones that are not prime?
(4) Write a Python program that computes rows of Pascal’s triangle. You can do this by iteration
or direct computation of binomial coefficients.
(5) Test the following conjecture with Python: let n = 2k . Then, xn ≡ 1 mod n if x is odd and
0 mod n if x is even.
(6) Test the following conjecture: let n = pq with p, q primes such that p < q. Then, xn ≡ xp
mod n.
(7) Use your Pascal’s triangle program to test the conjecture that if p is a prime, then every
element of the p-th row of Pascal’s triangle is divisible by p.
(8) Test the converse of the previous conjecture: if every element of the p-th row of Pascal’s
triangle is divisible by p, then p is prime.
1
Download