Write a program to determine whether a positive integer n


Question: A prime number has no factors besides 1 and itself. Do the following.

a. Write a program to determine whether a positive integer N is prime. In terms of N, what is the worst-case running time of your program?

b. Let B equal the number of bits in the binary representation of N. What is the value of B?

c. In terms of B, what is the worst-case running time of your program?

d. Compare the running times to determine whether a 20-bit number and a 40-bit number are prime.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Write a program to determine whether a positive integer n
Reference No:- TGS02475103

Now Priced at $15 (50% Discount)

Recommended (91%)

Rated (4.3/5)