Skip to main content
Glama

factorial

Calculate the factorial of a non-negative integer for mathematical computations and probability calculations.

Instructions

Calculate the factorial of a non-negative integer.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nYes

Implementation Reference

  • The factorial tool handler: validates that n is non-negative and not too large (>100), then computes and returns math.factorial(n).
    def factorial(n: int) -> int: """Calculate the factorial of a non-negative integer.""" if n < 0: raise ValueError("Factorial is not defined for negative numbers") if n > 100: raise ValueError("Number too large for factorial calculation") return math.factorial(n)
  • server.py:107-107 (registration)
    The @mcp.tool() decorator registers the factorial function as an MCP tool.
    @mcp.tool()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vipankumar87/MCP-Example'

If you have feedback or need assistance with the MCP directory API, please join our Discord server