Number Utilities

Is Power Of

Determines if one number is a power of another with mathematical precision. Call via MCP in Cursor or Windsurf, or hit GET /v1/number/is-power-of with base and number parameters. Returns true/false plus the exponent when valid. Perfect for algorithms needing exact power relationships without floating-point errors that plague manual calculations.

API Endpoint

GET /v1/number/is-power-of

Code Examples

curl "https://tinyfn.io/v1/number/is-power-of" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/number/is-power-of', {
  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/is-power-of',
    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 check if 64 is a power of 2 using the MCP tool?

Pass base=2 and number=64 to get true with exponent=6, since 2^6 = 64. Works in any MCP-enabled editor like Cursor or Claude Code.

What happens when I check if a number is a power of 1?

Any positive number is technically a power of 1, but the tool handles this edge case logically. Check the API response for specific behavior with base=1.

Can this detect negative bases and fractional powers?

The tool works with negative bases (like -2^3 = -8) but typically focuses on integer exponents. Fractional results depend on the specific implementation.

Why use this instead of logarithms for power detection?

Avoids floating-point precision errors that make log-based checks unreliable. Returns exact integer exponents when they exist, crucial for cryptography and algorithms.

What's the REST API format for checking power relationships?

GET /v1/number/is-power-of?base=3&number=27 returns JSON with boolean result and exponent value. Simple query parameters, structured response.

Try Is Power Of Now

Get your free API key and start using Is Power Of in seconds.

Get Free API Key