Crivo de Eratóstenes — contagem

conta primos ≤ N.
Created by
Renato Passos, Eng. de Software
Reviewed by
Renato Passos, Eng. de Software

Last updated: Apr 18, 2026

π(N)
25

About this calculator

The Sieve of Eratosthenes is a classical algorithm to identify all prime numbers up to a given number N. It works by iteratively removing multiples of each prime starting from 2. The calculator implements this method to count primes ≤ N, useful in number theory studies or programming. Its simplicity makes it ideal for educational purposes.

The algorithm doesn’t have a single formula but follows these steps: 1) Create a list from 2 to N. 2) Mark the first number (2) as prime. 3) Eliminate all its multiples. 4) Repeat with the next unmarked number. The final count is the number of remaining primes. This method is efficient for N up to ~10,000 due to computational limits.

Use this tool to solve math exercises, test prime distribution hypotheses, or optimize code requiring primality checks. For example, in cryptography or numerical algorithm design. It also helps visualize how primes become sparser in larger sequences.

Important notes: performance degrades for N > 100,000 due to high computational load. Results are exact only for integers N ≥ 2. Avoid excessively large inputs that may cause memory errors. For N ≥ 10^6, consider analytical methods like the prime-counting function π(x).

Frequently asked questions

How does the Sieve of Eratosthenes algorithm work?

It creates a list of numbers from 2 to N, marks the first number (2) as prime, and removes all its multiples. The process repeats with the next unmarked number until N. Remaining numbers are primes.

What are common use cases for prime counting?

It helps solve math problems, test numerical properties, and prepare data for algorithms requiring prime lists, such as cryptography.

What is the maximum recommended value for N?

N up to 10,000 is advised for fast results. Larger values may cause delays or memory issues depending on the device.

Is the result exact for all N?

Yes, as long as N is a positive integer ≥ 2. For decimals or N ≤1, the result will be 0 primes.

Does this calculator show the actual primes found?

No, it only displays the total count. Use detailed output versions to see the specific primes.

Other Teoria Números calculators