Math Utilities

Lcm

Calculate the least common multiple (LCM) of two or more integers with deterministic precision. Access via MCP in Cursor or Windsurf for AI-powered math workflows, or call GET /v1/math/lcm directly. Returns the smallest positive integer divisible by all inputs — essential for fraction operations, scheduling algorithms, and periodic calculations.

API Endpoint

GET /v1/math/lcm

Code Examples

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

{
  "mcpServers": {
    "tinyfn-math": {
      "url": "https://tinyfn.io/mcp/math",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I calculate LCM of multiple numbers using TinyFn?

Pass integers as query parameters to GET /v1/math/lcm?a=12&b=18&c=24. Returns the smallest number divisible by all inputs (72 in this case).

Can AI agents use LCM calculations in MCP workflows?

Yes, Cursor and other MCP-compatible editors can invoke the lcm tool directly. Perfect for automated scheduling, fraction arithmetic, or periodic pattern analysis.

What's the difference between LCM and GCD?

LCM finds the smallest common multiple, GCD finds the largest common divisor. For 12 and 18: LCM is 36, GCD is 6.

Does the LCM function handle negative numbers?

LCM is mathematically defined for positive integers. The function typically returns the LCM of absolute values since LCM represents the smallest positive common multiple.

What happens when calculating LCM with zero or one?

LCM with zero is undefined mathematically. LCM with 1 returns the other number since 1 divides everything (LCM(1, n) = n).

Try Lcm Now

Get your free API key and start using Lcm in seconds.

Get Free API Key