Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the time complexity in Big Oh of python's built in modular exponentiation function using pow? Ex: pow(a, b, c) Assume that both k

What is the time complexity in Big Oh of python's built in modular exponentiation function using pow? Ex: pow(a, b, c)

Assume that both k and n are n bits for simplicity sake Assume that division is O(n^2) Assume that multiplication is O(n^2) Assume that mod is O(n)

Here is my code:

def run_fermat(n, k):
if n == 1 or n == 0: # O(1) return 'composite' for i in range(0, k): # Here we look at k in n bits a = random.randint(1, n - 1) # O(1) if pow(a, n-1, n) != 1: # Modular exponentiation - this is faster than using our mod_exp function return 'composite' # Number is not prime return 'prime' # Number is prime

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Oracle Fusion Applications Installation And Administration

Authors: Tushar Thakker

1st Edition

1484209834, 9781484209837

More Books

Students also viewed these Databases questions