Home > Python > Basic Python Programs

Ch. 3.4 Finding All Prime Numbers Within a Given Range

Chapters Index
Program 1

Finding All Prime Numbers Within a Given Range

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

The code is executed with the defined range of 10 to 50, the steps are as follows:

Prime Checking:

The function prime(num) will be called for each number between 10 and 50.

For example:

  • prime(10) returns False (divisible by 2 and 5).
  • prime(11) returns True (not divisible by any number from 2 to 10).

This process continues for each number up to 50.