write a python program to
display all the prime numbers in the given range
class 11 (IP)
Answers
Answered by
3
Answer:
This is the required Python program for the question.
a=int(input("Enter starting range: "))
b=int(input("Enter ending range: "))
print(f"Prime numbers in the range {a} to {b} are as follows:")
for i in range(a,b+1):
c=0
for j in range(1,i+1):
if i%j==0:
c+=1
if c==2:
print(i,end=" ")
Algorithm:
- START.
- Accept the range.
- Iterate through the numbers in the range.
- Count the number of factors of each numbers in the range.
- If number_of_factors = 2, display the number.
- STOP.
Refer to the attachment.
•••♪
Attachments:
Similar questions