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.
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)
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"
}
}
}
}
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).
Yes, Cursor and other MCP-compatible editors can invoke the lcm tool directly. Perfect for automated scheduling, fraction arithmetic, or periodic pattern analysis.
LCM finds the smallest common multiple, GCD finds the largest common divisor. For 12 and 18: LCM is 36, GCD is 6.
LCM is mathematically defined for positive integers. The function typically returns the LCM of absolute values since LCM represents the smallest positive common multiple.
LCM with zero is undefined mathematically. LCM with 1 returns the other number since 1 divides everything (LCM(1, n) = n).