Using for loop
In [1]:
start = int(input("Please enter start number :"))
end = int(input("Please enter end number :"))
for number in range(start, end+1):
for i in range(2, number):
if (number % i == 0):
break
else:
print(number)
In this program, we ask the user to input the range as the start and end number. After that, a for loop is used to loop through the range. Another for loop is used to find that if the number is divisible by any number below it or not. And if not, then it is printed on the console.