Calculate the nth Fibonacci number using TinyFn's deterministic math endpoint. Access via MCP in Cursor or Windsurf for instant sequence generation, or call GET /v1/math/fibonacci?n=10 directly. Returns precise integers for any position in the sequence. Perfect when AI agents need exact mathematical computations instead of approximate answers.
curl "https://tinyfn.io/v1/math/fibonacci" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/math/fibonacci', {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests
response = requests.get('https://tinyfn.io/v1/math/fibonacci',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's math tools:
{
"mcpServers": {
"tinyfn-math": {
"url": "https://tinyfn.io/mcp/math",
"headers": {
"X-API-Key": "YOUR_API_KEY"
}
}
}
}
Call the fibonacci tool with n=50 through your MCP-enabled editor like Cursor or Claude Code. The tool returns the exact value: 12586269025.
The endpoint handles arbitrarily large Fibonacci numbers, limited only by computational resources. For practical use, values up to n=1000+ work reliably.
The API uses 1-based indexing: fibonacci(1)=1, fibonacci(2)=1, fibonacci(3)=2. This matches mathematical convention rather than programming arrays.
No, each request calculates a single Fibonacci number. For sequences, make multiple calls or use the deterministic nature to cache results efficiently.
AI agents get guaranteed correct results without implementing recursive algorithms. Eliminates off-by-one errors and handles edge cases like negative inputs automatically.