NewAPIVerve Academy: free courses and certifications anyone can verify.Explore the Academy →

Permutation & Combination Calculator API

GET

Solve permutations and combinations without writing custom math.

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

Try it — live request, no key required

Request
GETapi.apiverve.com/v1/permutationcombination?n=10&r=3
Query parameters
Verification
Format

No key required to try it. Get a key to use it in your app.

Example
{
  "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)!)"
    }
  }
}

About the Permutation & Combination Calculator API

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.

How it works

The calculator takes two non-negative integers, n (the size of the set, up to 170) and r (how many are chosen). r larger than n is rejected with a 400 rather than returning a meaningless count, and so is anything that is not a whole number.

permutation is P(n,r) = n! / (n-r)!, the number of ordered arrangements of r items taken from n. It is computed as the product of the integers from n-r+1 up to n, so the (n-r)! term cancels instead of being built and divided. combination is C(n,r) = n! / (r! (n-r)!), obtained by dividing that product by r!. Both run in exact big-integer arithmetic, which is why C(30,15) returns 155117520 rather than a value a fraction below it.

The results are converted to JSON numbers on the way out. Counts up to 2^53 are exact; larger ones, which appear quickly as n grows, come back as the nearest double, correctly rounded from the exact value, so leading digits and magnitude are right but trailing digits are not. The cap at 170 exists because 171! is larger than a double can hold. Edge cases follow the usual conventions: r = 0 gives 1 for both, and r = n makes the permutation equal to n! and the combination 1.

formulas holds the two expressions as text and is null on the Free plan.

What people use it for

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

Ways to call it

One endpoint, many ways in — REST with JSON, XML, YAML and CSV, plus GraphQL and an MCP interface for AI agents.

JSON
Default REST response
XML
Markup format
YAML
Human-readable
CSV
Tabular export
Beta
GraphQL
Query language
New
MCP
For AI agents

Other ways to use Permutation & Combination Calculator

Same data, same APIVerve account, same credit balance — one key works on all of them.

Questions.

Common questions about the Permutation & Combination Calculator API.

Read the docs →
Does a single request calculate both permutations and combinations?
Yes. Every request takes your total count of items and the number chosen, returning both the permutation P(n,r) and combination C(n,r) values in the same response.
Can I set the number of chosen items higher than the total items?
No. The parameter r must be less than or equal to n. Combinatorial calculations require choosing from an existing pool, so r cannot exceed the total number of items provided.
Are the mathematical formulas included on the Free plan?
No. The Free plan returns the calculated numerical results for permutations and combinations, but the step-by-step mathematical formulas are premium fields unlocked on paid plans like Starter.
Does the calculator accept decimal or negative numbers?
No. Both n and r must be integers. The calculation requires discrete whole numbers representing items in a set and items being chosen.
Which plan fits 50,000 combinatorial calculations a month?
The Starter plan covers this volume with room to spare. At 1 credit per call, 50,000 calculations use 50,000 of the 200,000 monthly credits on Starter, working out to about $0.15 per 1,000 calls. The Free plan gives you 200 calls each month for testing.

Ready to build with Permutation & Combination Calculator? Start with 200 free credits — one key unlocks all 300+ APIs.

Explore the catalog

300+ APIs on the same key and the same response shape.

Browse all APIs