Given two positive integers start and end. The task is to write a Python program to print all Prime numbers in an Interval.**Definition: **A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The first few prime numbers are {2, 3, 5, 7, 11, ….}.

The idea to solve this problem is to iterate the *val *from *start *to *end *using a for loop and for every number, if it is greater than 1, check if it divides *n*. If we find any other number which divides, print that value.

Below is the Python implementation:

## Python3

`# Python program to print all ` `# prime number in an interval` `#number should be greater than 1` `start ` `=` `11` `end ` `=` `25` `for` `i ` `in` `range` `(start,end):` ` ` `if` `i>` `1` `:` ` ` `for` `j ` `in` `range` `(` `2` `,i):` ` ` `if` `(i ` `%` `j` `=` `=` `0` `):` ` ` `break` ` ` `else` `:` ` ` `print` `(i)` |

*chevron_right*

*filter_none*

**Output: **

11 13 17 19 23

The above solution can be optimized using the Sieve of Eratosthenes. Please see print prime numbers in a range for details.

Attention geek! Strengthen your foundations with the **Python Programming Foundation** Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the **Python DS** Course.

## Recommended Posts:

- Program to find Prime Numbers Between given Interval
- Python Program to Print Numbers in an Interval
- Print numbers such that no two consecutive numbers are co-prime and every three consecutive numbers are co-prime
- Print all numbers whose set of prime factors is a subset of the set of the prime factors of X
- Python Program for Efficient program to print all prime factors of a given number
- How to create a NumPy 1D-array with equally spaced numbers in an interval?
- Print the nearest prime number formed by adding prime numbers to N
- Print prime numbers with prime sum of digits in an array
- Absolute difference between the Product of Non-Prime numbers and Prime numbers of an Array
- Absolute difference between the XOR of Non-Prime numbers and Prime numbers of an Array
- Count prime numbers that can be expressed as sum of consecutive prime numbers
- Count all prime numbers in a given range whose sum of digits is also prime
- Python | Interval Initialization in list
- Python | sympy.Interval().intersect() method
- Python | sympy.Interval().contains() method
- Python | sympy.Interval().inf attribute
- Python | Scipy stats.halfgennorm.interval() method
- Python | Scipy stats.hypsecant.interval() method
- Python | Interval List Summation
- Python | Reverse Interval Slicing String

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.