Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I really need assistance with this one!!! Using Python. A composite number n is an integer that is evenly divisible by a integer in 2..(

I really need assistance with this one!!! Using Python.

A composite number n is an integer that is evenly divisible by a integer in 2..(n-1). A prime number n is an integer that is only evenly divisible by 1 and n. So, 4 and 12 are composite numbers while 3 and 11 are prime numbers. Write a fruitful function called composite(n) that yields True if n is composite and yields False if n is prime. Then write a function called composite_range(a, b) that calls composite() to find and display all the composite numbers in the range a..b (inclusive). Finally, write a main driver that asks the user for a range (lower bound and upper bound) and then calls composite_range() to display all the composites in the requested range. Your driver should repeat until the user provides a range where a is zero.

Here is what I have, but it returns a value of None:

def composite(n): if(n >= 2 and n % 2 == 0): return True else: return False def composite_range(a,b): for i in range(a, b + 1): num_total = i composite_range = composite(num_total) count = 0 for j in range(1, a + 1): if num_total % j == 0: count += 1 break low_bound = int(input('lower bound: ')) up_bound = int(input('upper bound: ')) print(' Composites in the range', low_bound,'-',up_bound,': ')

print(composite_range(low_bound, up_bound), end=" ")

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

Lab Manual For Database Development

Authors: Rachelle Reese

1st Custom Edition

1256741736, 978-1256741732

More Books

Students also viewed these Databases questions

Question

Determine the distribution function of min0yt X(y).

Answered: 1 week ago