#Python program to display all the prime numbers within an interval
# change the values of lower and upper for a different result
lower = 900
upper = 1000
# uncomment the following lines to take input from the user
#lower = int(input("Enter lower range: "))
#upper = int(input("Enter upper range: "))
print("Prime numbers between",lower,"and",upper," are:")
for num in range(lower,upper + 1):
907
911
919
929
937
941
947
953
967
971
977
983
991
997
# change the values of lower and upper for a different result
lower = 900
upper = 1000
# uncomment the following lines to take input from the user
#lower = int(input("Enter lower range: "))
#upper = int(input("Enter upper range: "))
print("Prime numbers between",lower,"and",upper,"
for num in range(lower,upper + 1):
# prime numbers are greater than 1
if num > 1:
if num > 1:
for i in range(2,num):
if (num % i) == 0:
break
else:
print(num)
Output:
Prime numbers between 900 and 1000 are:907
911
919
929
937
941
947
953
967
971
977
983
991
997
0 Comments:
Post a Comment