Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use python 3.8: Design a function called count_primes_in_range that takes two arguments: a.an integer representing the minimum value of a number range to search

Please use python 3.8:

Design a function called count_primes_in_range that takes two arguments: a.an integer representing the minimum value of a number range to search b.an integer representing the maximum value of a number range to search

The count_primes_in_range function calculates and returns the number of prime numbers found in the range starting at the minimum value, going up to and including the maximum value. For example: count_primes_in_range(7, 13) returns 3, since there are 3 prime numbers in the range from 7 to 13 (7, 11, and 13).

Important: The implementation of your function must include a call to one of the other functions below:

def is_factor(n1, n2): """ returns true if n1 is a factor of n2, false otherwise Preconditions: n1 > 0 """ return (n2 % n1 == 0)

def num_facotrs(n): """ returns the number of factors of the integer Preconditions: The integer given is greater than 0. """ count = 0 for i in range1,n+1,1): if is_factor(i,n): count = count + 1 return count

def is_prime(n): """ returns true if n is a prime number, false otherwise. Precondition: The integer given is greater than or equal to 2. """ return num_factors(n) == 2

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

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago