Ask anything, write code, analyze data, and create content. Cortex understands context, remembers your preferences, and gets smarter with every conversation.
From quick answers to complex multi-step tasks, Cortex adapts to how you work.
Get instant, accurate answers across every topic from science to coding to creative writing.
Generate, debug, and refactor code in any language. From algorithms to full-stack apps.
Upload datasets, get insights, build charts, and find patterns in your data effortlessly.
Draft emails, blog posts, marketing copy, and creative stories tailored to your voice.
Write a Python function that finds all prime numbers up to n.
Here is an efficient Sieve of Eratosthenes implementation:
def sieve_of_eratosthenes(n: int) -> list[int]:
"""Find all prime numbers up to n."""
if n < 2:
return []
is_prime = [True] * (n + 1)
is_prime[0] = is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
if is_prime[i]:
for j in range(i*i, n + 1, i):
is_prime[j] = False
return [i for i in range(n + 1) if is_prime[i]]Time complexity: O(n log log n). This is optimal for generating all primes up to n.
Start for free, upgrade when you need more.
Get started with basic AI chat capabilities.
For professionals who need advanced AI features.
For teams that need security, control, and scale.
Edit the CSS custom properties below and click Apply to see changes live. Copy the config to use in your own project.