# Permutation & Combination Calculator API

> Calculate permutations (P(n,r)) and combinations (C(n,r)) for any given values of n and r.

**Endpoint:** `GET https://api.apiverve.com/v1/permutationcombination`  
**Category:** Math/Calculations  
**Cost:** 1 credit per call  
**Canonical page:** https://apiverve.com/marketplace/permutationcombination

## Overview

Permutation & Combination Calculator works out nPr and nCr for any total n and selection size r. Send the two integers and get back the number of ordered arrangements, P(n,r), and the number of unordered selections, C(n,r), in one call. It is built for probability calculations, statistics problems, and combinatorial analysis where you need the count rather than a list of the arrangements themselves.

Typical uses include lottery and card-hand odds, the number of possible seating orders or race finishes, how many teams can be drawn from a squad, and checking homework or quiz answers in an education app. Because the result is computed exactly on the server, large inputs do not come back with fractional counts or factorial rounding drift.

The Free plan returns n, r and both results. Paid plans add the formulas used for each calculation, written out in factorial notation, which is useful when the answer is displayed to learners next to the working.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl "https://api.apiverve.com/v1/permutationcombination?n=10&r=3" \
  -H "x-api-key: YOUR_API_KEY"
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `n` | integer | Yes | Total number of items. range 0-170 |
| `r` | integer | Yes | Number of items to choose (must be <= n). range 0-170 |

## Response fields

- `n` — number · Total number of items used in calculation
- `r` — number · Number of items chosen in calculation
- `permutation` — number · Calculated permutation P(n,r) result value
- `combination` — number · Calculated combination C(n,r) result value
- `formulas` — object · Object containing mathematical formulas for permutation and combination · (premium)
  - `formulas.permutation` — string · Mathematical formula used for permutation calculation · (premium)
  - `formulas.combination` — string · Mathematical formula used for combination calculation · (premium)

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "n": 10,
    "r": 3,
    "permutation": 720,
    "combination": 120,
    "formulas": {
      "permutation": "P(n,r) = n! / (n-r)!",
      "combination": "C(n,r) = n! / (r! × (n-r)!)"
    }
  }
}
```

## Use cases

- **Education** — Solve permutation and combination problems for homework and exams
- **Probability** — Calculate odds and probabilities in statistics
- **Programming** — Determine algorithm complexity and counting problems
- **Game Design** — Calculate possible combinations for game mechanics

## SDKs

- **npm** — `npm install @apiverve/permutationcombination` (https://www.npmjs.com/package/@apiverve/permutationcombination)
- **NuGet** — `dotnet add package APIVerve.API.PermutationCombinationCalculator` (https://www.nuget.org/packages/APIVerve.API.PermutationCombinationCalculator)
- **Source** — https://github.com/apiverve/permutationcombination-api

## More

- Full reference: https://docs.apiverve.com/ref/permutationcombination
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
