# Combinatorics Calculator

> Calculate combinatorial values with modular arithmetic

- Skill: `a5c-ai/combinatorics-calculator` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add a5c-ai/combinatorics-calculator`
- Raw SKILL.md: https://api.skillmd.com/api/skills/a5c-ai/combinatorics-calculator/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: a5c-ai (https://skillmd.com/u/a5c-ai)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/a5c-ai/combinatorics-calculator

---


# Combinatorics Calculator Skill

## Purpose

Calculate combinatorial values with modular arithmetic support for competitive programming applications.

## Capabilities

- Factorial and inverse factorial precomputation
- nCr, nPr with modular arithmetic
- Catalan, Stirling, Bell numbers
- Lucas theorem implementation
- Inclusion-exclusion principle application
- Generating functions

## Target Processes

- combinatorics-counting
- number-theory-algorithms
- dp-pattern-matching

## Combinatorial Functions

### Basic Counting
- Factorial: n!
- Permutations: P(n,r) = n!/(n-r)!
- Combinations: C(n,r) = n!/(r!(n-r)!)

### Special Numbers
- Catalan numbers
- Stirling numbers (first and second kind)
- Bell numbers
- Derangements

### Advanced Techniques
- Lucas theorem (for large n, small p)
- Inclusion-exclusion
- Burnside's lemma
- Generating functions

## Input Schema

```json
{
  "type": "object",
  "properties": {
    "operation": {
      "type": "string",
      "enum": ["nCr", "nPr", "factorial", "catalan", "stirling", "lucas", "precompute"]
    },
    "n": { "type": "integer" },
    "r": { "type": "integer" },
    "mod": { "type": "integer" },
    "precomputeLimit": { "type": "integer" }
  },
  "required": ["operation"]
}
```

## Output Schema

```json
{
  "type": "object",
  "properties": {
    "success": { "type": "boolean" },
    "result": { "type": "integer" },
    "code": { "type": "string" },
    "formula": { "type": "string" }
  },
  "required": ["success"]
}
```

