Answer to Question #227334 in Python for srikanth

Question #227334
Composite Numbers in the range

You are given two integers 

M, N as input. Write a program to print all the composite numbers present in the given range (including M and N).

Input

The first line of input is an integer 

M. The second line of input is an integer N.

Explanation

In the given example, the composite numbers present in the range between 

2 to 9 are 4, 6, 8, 9.

So, the output should be

4
6
8
9
Sample Input 1
2
9
Sample Output 1
4
6
8
9
Sample Input 2
1
4
Sample Output 2
4

1
Expert's answer
2021-08-19T14:35:02-0400
M = int(input())
N = int(input())

for number in range(M,N+1):
    count = 0
    #divisor search, do not count the number itself and 1
    for divider in range(2,number//2+1):
        if number%divider == 0:
            count+=1
    if count >= 1:
        print(number)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

sandy
20.09.22, 07:37

WORKING!!!!!!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS