Connection
Base URL, credentials and a reachable server.
List all primes up to an inclusive integer limit using a sieve capped at 1000000.
Base URL, credentials and a reachable server.
A model available through the configured endpoint.
Context limits and tool support are determined by the model and server.
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]