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
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