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.
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)
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"
}
}
}
}
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.
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.
The tool works with negative bases (like -2^3 = -8) but typically focuses on integer exponents. Fractional results depend on the specific implementation.
Avoids floating-point precision errors that make log-based checks unreliable. Returns exact integer exponents when they exist, crucial for cryptography and algorithms.
GET /v1/number/is-power-of?base=3&number=27 returns JSON with boolean result and exponent value. Simple query parameters, structured response.