Sunday, 2 October 2016

prime numbers from upper range to lower range

a=int(input("enter lower range="))
b=int(input("enter upper range="))

for num in range(a,b+1):
   # prime numbers are greater than 1
   if num > 1:
       for i in range(2,num):
           if (num % i) == 0:
               break
       else:
           print(num)

No comments:

Post a Comment