Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is another algorithm for discovering prime integers. A prime number is an integer greater than 1 whose only factors are 1 and itself. Rewrite

Here is another algorithm for discovering prime integers. A prime number is an integer greater than 1 whose only factors are 1 and itself.
Rewrite this code as a user defined function. The function will take two arguments specifying range of integers to be considered, the first argument being the lower and the second being the upper.
Be sure to use this algorithm and not some other.
The function will return a list of prime integers within the specified range. For example, if your function is passed 2 and 50 as arguments, it will return this list:
2,3,5,7,11,13,17,19,23,29,31,37,41,43,47
If it is passed 100 and 150 as arguments, it will return
[101,103,107,109,11127,131,137,139,149]
Here is the code to be adapted as a user defined function:
for i in range (2,50) :
if i=0 or i=1 :
continue
else:
for j in range(2, int (i2)+1 :
if i%j=0 :
else:
break
print(i)
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

What is your current role and what are your responsibilities?

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago