Given two numbers and as interval range, the task is to find the prime numbers in between this interval.
Input : a = 1, b = 10 Output : 2, 3, 5, 7 Input : a = 10, b = 20 Output : 11, 13, 17, 19
In the below program, the range of numbers is taken as input and stored in the variables ‘a’ and ‘b’. Then using for-loop, the numbers between the interval of a and b are traversed. For each number in the for loop, it is checked if this number is prime or not. If found prime, print the number. Then the next number in the loop is checked, till all numbers are checked.
Enter lower bound of the interval: 1 Enter upper bound of the interval: 10 Prime numbers between 1 and 10 are: 2 3 5 7
- Python program to print all Prime numbers in an Interval
- Program to find sum of prime numbers between 1 to n
- Find the XOR of first N Prime Numbers
- Find two prime numbers with given sum
- Absolute difference between the Product of Non-Prime numbers and Prime numbers of an Array
- Find the sum of prime numbers in the Kth array
- Find count of Almost Prime numbers from 1 to N
- Find out the prime numbers in the form of A+nB or B+nA
- Find the Product of first N Prime Numbers
- Find product of prime numbers between 1 to n
- Find two distinct prime numbers with given product
- Find a sequence of N prime numbers whose sum is a composite number
- Find the prime numbers which can written as sum of most consecutive primes
- Absolute difference between the XOR of Non-Prime numbers and Prime numbers of an Array
- Absolute Difference between the Sum of Non-Prime numbers and Prime numbers of an Array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.