Finding the Mth Prime Number Write a well-documented Python program, hmwk3Q1.py that finds the Mth prime number by extending hmwk2Q3.py, which finds the prime number for a single number. Have your program query the user for the integer M. Print the value of the 908th prime number and record it as a comment in your Python program. Hints: Re-use hmwk2Q3.py software by embedding it in a while-loop. The while-loop continues to call upon the prime number code until it finds the 908th prime number. Make sure that inside the while-loop you implement a counter, which is incremented when a prime number is found.
Finding the Mth Prime Number Write a well-documented Python program, hmwk3Q1.py that finds the Mth prime number by extending hmwk2Q3.py, which finds the prime number for a single number. Have your program query the user for the integer M. Print the value of the 908th prime number and record it as a comment in your Python program. Hints: Re-use hmwk2Q3.py software by embedding it in a while-loop. The while-loop continues to call upon the prime number code until it finds the 908th prime number. Make sure that inside the while-loop you implement a counter, which is incremented when a prime number is found.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Finding the Mth prime number
![print("Is The Integer Prime?")
#ask the user to input an integer N
N = int(input("Enter an integer: "))
# initialize an empty list to store the factors
factors = []
#loop through the integers from 1 to N-1
for i in range(2, N):
#check if i is a factor of N
if N % i == 0:
#ifi is a factor, append it to the list of factors
factors.append(i)
#check if the length of the list of factors is 0
if len(factors) == 0:
#if the length of the list of factors is 0, N is a prime number
print(f"{N} is Prime")
else:
# if the length of the list of factors is not 0, N is not a prime number
print(f"{N} is not Prime")](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd8cbd1f0-fbe3-46ea-b49e-77385d6c8a18%2Fd83b38ff-777d-4a20-a74e-b6639974ad3d%2F2frtd4n_processed.jpeg&w=3840&q=75)
Transcribed Image Text:print("Is The Integer Prime?")
#ask the user to input an integer N
N = int(input("Enter an integer: "))
# initialize an empty list to store the factors
factors = []
#loop through the integers from 1 to N-1
for i in range(2, N):
#check if i is a factor of N
if N % i == 0:
#ifi is a factor, append it to the list of factors
factors.append(i)
#check if the length of the list of factors is 0
if len(factors) == 0:
#if the length of the list of factors is 0, N is a prime number
print(f"{N} is Prime")
else:
# if the length of the list of factors is not 0, N is not a prime number
print(f"{N} is not Prime")

Transcribed Image Text:Finding the Mth Prime Number
Write a well-documented Python program, hmwk3Q1.py that finds the Mth prime number by extending hmwk2Q3.py,
which finds the prime number for a single number. Have your program query the user for the integer M. Print the value
of the 908th prime number and record it as a comment in your Python program.
Hints:
Re-use hmwk2Q3.py software by embedding it in a while-loop. The while-loop continues to call upon the prime number
code until it finds the 908th prime number. Make sure that inside the while-loop you implement a counter, which is
incremented when a prime number is found.
Expert Solution

Explanation
1) Below is python program to find Nth prime number
- It display's the message to user for prime checking
- Ask user to enter an integer using input function, convert it to integer and assign it to num variable
- Initialize number and prime count
- Run loop to continue call upon prime numbers
- Initialize an empty list to store the factors
- Loop through integers from 2 to number
- Check if i is a factor of count
- append the factor with prime number
- Check if i is a factor of count
- If length of factors is 0, means it is a prime number
- increase prime count
- If prime count the user selected number, display prime and break from while loop
- increment number to check for next prime
2) Save program in python file hmwk2Q3.py and run
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY