Number Utilities

Prime Factors

Prime Factors decomposes integers into their constituent prime numbers using trial division. Access via MCP in Cursor or Windsurf, or call GET /v1/number/factors directly. Input 60, get [2, 2, 3, 5]. Returns factors in ascending order with repetition for powers — essential for cryptography, algorithm optimization, and mathematical analysis where deterministic factorization matters.

API Endpoint

GET /v1/number/factors

Code Examples

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

Returns a JSON array of prime factors in ascending order with repetition. For example, 12 returns [2, 2, 3], and 17 returns [17].

How can AI agents use prime factorization in MCP workflows?

Agents can factor numbers for cryptographic key analysis, algorithm complexity calculations, or mathematical problem solving. Integrates directly with Cursor and other MCP-enabled editors.

What's the largest number I can factor with this tool?

Handles standard integers efficiently, but very large numbers may timeout due to computational complexity. Prime factorization becomes exponentially harder with larger inputs.

Does the API handle edge cases like 1, 0, or negative numbers?

Typically returns empty array for 1, and handles 0 and negatives according to mathematical conventions. Check specific error responses for boundary conditions.

How does this compare to built-in language factorization functions?

Provides consistent, deterministic results across platforms without requiring math libraries. Useful when you need reliable factorization in web APIs or cross-language workflows.

Try Prime Factors Now

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

Get Free API Key