CSCI 3104 - Algorithms - Fall 2013

Problem Set #3

Due: 11am, Sep 26th, 2013



1. Text problem 1.16.

2. Text problem 1.20. Do not use a computer; show your work.

3. What is the smallest integer that is simultaneously a 2-pseudoprime, a 3-pseudoprime and a 2013-pseudoprime? Use a computer to search; include your source code.

4. Write a python function getrand100() to generate random 100-digit positive numbers. Write a second function nextprime(i) to find the next prime ≥ i. What is nextprime(2013**50)? Include the answer along with your source code.

5. Using your code from above, write a python program that computes the average distance from a selected integer to the nextprime after it. Use 1 thousand samples to obtain your average. In other words, let s=getrand100() and then compute the average value of nextprime(s)-s using 1000 samples. Include source code with your answer.