Question: USING PYTHON. Recall that Fermat's Little Theorem says that for a prime p and integer a with ged(a,p) -1, we have that a1 1 (mod
USING PYTHON.
Recall that Fermat's Little Theorem says that for a prime p and integer a with ged(a,p) -1, we have that a1 1 (mod p), or equivalently amod p 1 The contrapositive gives us a primality test. Specifically, suppose we want to test if a positive integer n is composite. Fix an integer a such that ged(a, n)-1 If an mod n 1, then n is not prirne. Write a function maybeprime which takes as input positive integer n and a prime a and outputs True if a -n or amod n, and False otherwise. Be sure to use fast exponentiation. Note that for a fixed positive integer n, if maybeprime (n,a) returns True for several prime values of a, then it is perhaps likely that n is prime. Write a function probablyprime that takes as input a positive integer n that returns true if maybeprime (n,a) returns True for a E2,3,5,7\ and False otherwise 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
