A prime number has only two divisors: itself and one.
5, 13, 59.
The number 1 has only one divisor, so it is not a prime number.
To find out if a number is prime, orderly divide by prime numbers less than it. When there is no exact division result and a quotient less than or equal to the divisor is obtained, it is said that the number is prime.
So, 179 is a prime number.
Sieve of Eratosthenes
The sieve of Eratosthenes is an algorithm that allows one to find all the prime numbers less than a given natural number.
Start with a list of numbers ranging from 2 up to a certain number.
Eliminate the multiples of 2 from the list.
Then, take the first number after the 2 that was not eliminated. In this case, (3) and eliminate their multiples from the list, and so on.
The process ends when the square of the largest number confirmed as a prime number is less than the final number on the list.
At this point, the numbers that remain on the list are prime numbers.
Calculate this algorithm for all prime numbers less than 40.
1. First, write the numbers. In this case they will be between 2 and 40.
2. Remove the multiples of 2.
3. The next number in the list is 3. Since 32 < 40, eliminate the multiples of 3.
4. The next number in the list is 5. Since 52 < 40, eliminate the multiples of 5.
5. The next number in the list is 7. Since 72 > 40, the algorithm ends and the numbers that remain are prime.
Table of prime numbers