Write a program in python to print all prime numbers in an Interval.

A number is said to be **Prime** if it **doesn’t have any factors other than 1 and itself**. Example: 3, 5, 7, etc.

To print all prime numbers in python we have to:

- Loop through all elements in the given interval.
- Check for each number if it has any factor between 1 and itself.
- If yes then it is not prime, move to next number.
- Else it is a Prime.

Let’s see the implementation of the same in python.

1 2 3 4 5 6 7 8 9 10 11 12 13 | lower = int(input("Enter the lower Interval value: ")) upper = int(input("Enter the upper Interval value: ")) #loop through the Interval and check individually for num in range(lower, upper+1): #Number should not be divisible #by any number between 1-num for x in range(2,num): if num%x==0: break else: print(num) |

**Output**

Check out more python programming examples.