Number Utilities

Primes In Range

Returns all prime numbers within a specified range using efficient sieve algorithms. Access via MCP in Cursor or Windsurf, or call GET /v1/number/primes-in-range with start and end parameters. For example, range 10-30 returns [11, 13, 17, 19, 23, 29]. Deterministic computation eliminates AI hallucination of incorrect prime sequences.

API Endpoint

GET /v1/number/primes-in-range

Code Examples

curl "https://tinyfn.io/v1/number/primes-in-range" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/number/primes-in-range', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/number/primes-in-range',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's number tools:

{
  "mcpServers": {
    "tinyfn-number": {
      "url": "https://tinyfn.io/mcp/number",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I get primes between two numbers using MCP?

Call the primes-in-range tool with start and end parameters. Claude Code and other MCP clients will return the exact prime array without guessing.

What's the maximum range I can query for primes?

The tool handles ranges efficiently up to reasonable computational limits. Very large ranges may timeout, so break them into smaller chunks if needed.

Does primes-in-range include the endpoint numbers?

Yes, both start and end values are included if they're prime. Range 2-7 returns [2, 3, 5, 7] since all endpoints are prime.

What format does the prime range API return?

Returns a JSON array of integers in ascending order. Empty ranges return an empty array [].

How is this better than asking AI to list primes?

AI often generates incorrect prime sequences or misses numbers. This tool uses proven algorithms to guarantee mathematically accurate results every time.

Try Primes In Range Now

Get your free API key and start using Primes In Range in seconds.

Get Free API Key