A prime number is a natural number which is greater than 1 and has no positive divisor other than 1 and itself, such as 2, 3, 5, 7, 11, 13, and so on.
The user is given two integer numbers, lower value, and upper value. The task is to write the Python program for printing all the prime numbers between the given interval (or range).
To print all the prime numbers between the given interval, the user has to follow the following steps:
- Step 1: Loop through all the elements in the given range.
- Step 2: Check for each number if it has any factor between 1 and itself.
- Step 3: If yes, then the number is not prime, and it will move to the next number.
- Step 4: If no, it is the prime number, and the program will print it and check for the next number.
- Step 5: The loop will break when it is reached to the upper value.
Output:
Conclusion
In this tutorial, we have shown how to write the code to print the prime numbers between the given interval of numbers.
need an explanation for this answer? contact us directly to get an explanation for this answer