Prime Sieve
Find all prime numbers up to a given limit using the Sieve of Eratosthenes. Visualize primes in a grid.
Number grid (primes highlighted)
Highlighted = prime number
Prime numbers
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
About this tool
A prime sieve is a mathematical algorithm that efficiently finds all prime numbers up to a specified limit. The Sieve of Eratosthenes, developed over two thousand years ago, remains one of the fastest methods for generating lists of primes and is widely used in cryptography, number theory research, and educational settings. This tool brings that classic algorithm to your browser, allowing you to explore the distribution and properties of prime numbers interactively.
To use this tool, enter the upper limit of your search range and click "Find Primes." The tool will instantly display all prime numbers up to that limit in a grid format, making it easy to visualize their frequency and patterns. Common use cases include verifying prime numbers for educational projects, generating primes for encryption algorithms, studying the gaps between consecutive primes, and exploring mathematical curiosities about prime distribution.
The Sieve of Eratosthenes works by iteratively marking the multiples of each prime as composite, leaving only the primes unmarked. This method is much faster than checking each number individually for divisibility. For limits under one million, the computation completes almost instantly; larger limits may take a few seconds depending on your device. This tool is perfect for students, mathematicians, and anyone curious about the fundamental building blocks of number theory.
Frequently Asked Questions
Code Implementation
def sieve_of_eratosthenes(limit: int) -> list[int]:
"""Return list of all primes up to limit."""
if limit < 2:
return []
is_prime = [True] * (limit + 1)
is_prime[0] = is_prime[1] = False
i = 2
while i * i <= limit:
if is_prime[i]:
for j in range(i * i, limit + 1, i):
is_prime[j] = False
i += 1
return [n for n, p in enumerate(is_prime) if p]
primes = sieve_of_eratosthenes(100)
print(primes)
# [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, ...]
print(f"Count: {len(primes)}") # Count: 25Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.