Computer Science, asked by Anonymous, 12 days ago

write a python program to
display all the prime numbers in the given range

class 11 (IP)​

Answers

Answered by anindyaadhikari13
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:

  1. START.
  2. Accept the range.
  3. Iterate through the numbers in the range.
  4. Count the number of factors of each numbers in the range.
  5. If number_of_factors = 2, display the number.
  6. STOP.

Refer to the attachment.

•••♪

Attachments:
Similar questions