Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started