Prime debugging¶
Topic: debugging
- Task:
Debug and fix the prime number search.
Count the number of primes that are \(\le 1999\).
Template: primes.py
- Further reading:
primes.py¶
- primes.count_primes(max)[source]¶
This function is supposed to search for prime numbers up to a given maximum value.
The program uses a modified Sieve of Eratosthenes algorithm. For each number, the program tests if smaller numbers divide the integer being checked. If no divisor is found, the number is a prime.
Unfortunately, the program does not work.
Note
This function is incomplete!
- Parameters:
max (int) – the maximum number to be tested
- Returns:
number of prime numbers between 2 and max
- Return type:
int