If that occurs, then the number has a divisor other than 1 and the number itself and the number isn’t a prime number. The most naive and straightforward implementation is to loop over the range of numbers from 2 to the number and see if the modulo of the number and the range is equal to 0. Let’s take a look at how we can use Python to determine if a number is a prime number. Finding Prime Numbers in Python (Optimized Code) The first few prime numbers are: 3, 7, 11, 13, etc.
For example, the number 5 is a prime number, while the number 6 isn’t (since 2 x 3 is equal to 6). Prime numbers are a positive integer that’s greater than 1 that also have no other factors except for 1 and the number itself.
Comparing Performance of Prime Number Functions.Finding Prime Numbers in Python (Optimized Code).