Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

print(Is The Integer Prime ?) # ask the user to input an integer N N= int(input(Enter an integer: )) # initialize an empty list to

image text in transcribedimage text in transcribed

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 N1 for i in range (2,N) : \# check if i is a factor of N if N%i=0 : \# if i 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") 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

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

More Books

Students also viewed these Databases questions