SSieveFern
Product

Product features · Bounded prime sieves

01

List all primes up to an inclusive integer limit using a sieve capped at 1000000.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Bounded prime sieves

● ● ●SieveFern●
A concrete starting point · Bounded prime sieves ×
from math import isqrt

def primes_through(limit):
    if type(limit) is not int or not 0 <= limit <= 1000000:
        raise ValueError("limit.range")
    sieve = bytearray([1]) * (limit + 1)
    sieve[0] = 0
    if limit >= 1:
        sieve[1] = 0
    for p in range(2, isqrt(limit) + 1):
        if sieve[p]:
            for multiple in range(p * p, limit + 1, p):
                sieve[multiple] = 0
    return [i for i, prime in enumerate(sieve) if prime]
✳List all primes up to an inclusive integer limit using a sieve capped at 1000000.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗