Number Utilities

Nth Triangular

Calculates the nth triangular number using the formula n(n+1)/2. Access via MCP in Cursor or Windsurf for instant mathematical computations, or call GET /v1/number/triangular with parameter n. Returns precise results for sequence problems, combinatorics, and algorithmic challenges without manual calculation errors.

API Endpoint

GET /v1/number/triangular

Code Examples

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

A triangular number is the sum of consecutive integers from 1 to n (1+2+3+...+n). The nth triangular number equals n(n+1)/2, so the 5th triangular number is 5×6/2 = 15.

Can I use this MCP tool for large triangular number calculations in Claude Code?

Yes, the MCP tool handles arbitrarily large integers without overflow issues. Perfect for mathematical analysis, algorithm verification, or generating test data in your development environment.

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

Send GET /v1/number/triangular?n=10 to get the 10th triangular number (55). Returns JSON with the result and handles edge cases like n=0 returning 0.

How do triangular numbers relate to combinatorics problems?

Triangular numbers represent combinations C(n+1,2) - the number of ways to choose 2 items from n+1 items. Useful for counting pairs, graph edges, or handshake problems.

What happens with negative input values or zero?

Zero returns 0 (valid triangular number), while negative inputs typically return an error. The sequence is undefined for negative integers in standard mathematical contexts.

Try Nth Triangular Now

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

Get Free API Key