Menu Close

Find prime numbers between lower and upper ranges

Write a program to find prime numbers between two range excluding the starting and ending number of given range

Input 1: Lower Range

Input 2: Upper Range

Output:
List of prime numbers

n1=int(input("Enter the lower range: "))
n2=int(input("Enter the upper range: "))

list=[]

for i in range(n1+1,n2):
  X=0
  for j in range(2,11):
    if (i%j==0):
      X=X+1
      break
  if (X==0):
    list.append(i)

print("Prime numbers between {} and {} are:".format(n1,n2))
for i in range(len(list)):
  print(list[i])

Input_1:
Enter the lower range: 17         
Enter the upper range: 23

Output:         
Prime numbers between 17 and 23 are:         
19


Input_2:
Enter the lower range: 11
Enter the upper range: 31

Output:
Prime numbers between 11 and 31 are:
13
17
19
23
29

Scrshot:

More Codes to Fcuk