Skip to main content
Glama

factorial

Use this tool to compute the factorial of a number, essential for mathematical and algorithmic calculations within the Zerodha Trading Bot’s automated trading operations.

Instructions

This tool calculates the factorial of a number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • index.js:40-46 (handler)
    The handler function computes the factorial of the input number 'a' using a for loop starting from 2 to 'a', multiplying accumulatively.
    async ({ a }) => { let ans = 1; for (let i = 2; i <= a; i++) ans *= i; return { content: [{ type: "text", text: `${ans}` }], }; }
  • Zod schema defining the input parameter 'a' as a number.
    { a: z.number() },
  • index.js:36-47 (registration)
    Registration of the 'factorial' MCP tool using McpServer.tool, including name, description, schema, and inline handler.
    server.tool( "factorial", "This tool calculates the factorial of a number", { a: z.number() }, async ({ a }) => { let ans = 1; for (let i = 2; i <= a; i++) ans *= i; return { content: [{ type: "text", text: `${ans}` }], }; } );

Other Tools

Related Tools

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/yogendhra9/ZerodhaMCP'

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