Number Utilities

Nth Prime

Retrieves the nth prime number through deterministic computation. Access via MCP in Cursor or Windsurf for AI-powered mathematical workflows, or call GET /v1/number/nth-prime with position parameter. Returns exact primes up to large positions without approximation — the 1000th prime is 7919, computed precisely every time.

API Endpoint

GET /v1/number/nth-prime

Code Examples

curl "https://tinyfn.io/v1/number/nth-prime" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/number/nth-prime', {
  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/nth-prime',
    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

What's the difference between nth prime and checking if a number is prime?

Nth prime finds the prime at a specific position (e.g., 10th prime = 29), while primality testing checks if a given number is prime. Use nth prime for sequence generation, primality testing for validation.

How do I get the 100th prime number using MCP in Cursor?

Call the nth-prime tool with position parameter 100. The AI agent will return 541, the exact 100th prime, computed deterministically without needing to generate all preceding primes.

What's the largest nth prime I can request?

The tool handles large positions efficiently, though response time increases with position. Positions up to several thousand work reliably — practical limits depend on your timeout settings.

Does the API use 0-based or 1-based indexing for prime positions?

Uses 1-based indexing where position 1 returns 2 (first prime), position 2 returns 3 (second prime), etc. This matches mathematical convention for prime sequences.

Can I get multiple consecutive primes or just single positions?

This endpoint returns a single prime at the specified position. For ranges or multiple primes, make separate calls or use other prime-related tools if available.

Try Nth Prime Now

Get your free API key and start using Nth Prime in seconds.

Get Free API Key