Number Utilities

Nth Square

Calculates the nth square number (n²) with perfect precision. Call via MCP in Cursor or Windsurf, or hit GET /v1/number/square?n=5 for REST. Returns 25 for n=5, 10000 for n=100. Handles arbitrarily large integers without floating-point errors that plague standard math libraries.

API Endpoint

GET /v1/number/square

Code Examples

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

Nth square calculates n², while square root finds the number that when squared equals the input. This tool gives you 5² = 25, not √25 = 5.

How do I use the nth square tool in MCP with Claude Code?

Simply ask Claude to find the nth square number. The MCP tool handles the computation automatically, returning precise integer results without JavaScript's floating-point limitations.

What happens with very large numbers like n=999999?

Returns exact results without precision loss. While JavaScript's Math.pow() might introduce floating-point errors at large scales, this tool maintains perfect integer accuracy.

Can I square negative numbers with this tool?

Yes, it handles negative integers correctly. (-5)² returns 25, following standard mathematical rules where negative numbers squared become positive.

What's the REST API format for getting square numbers?

GET /v1/number/square?n=VALUE returns JSON with the squared result. Example: ?n=12 returns {"result": 144}.

Try Nth Square Now

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

Get Free API Key