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:

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

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

Output

all prime numbers between 10 to 20

Check out more python programming examples.

Leave a Reply