Counting formulas

Combinatorics calculator

Educational tool; results are estimates for learning, verify with your textbook or instructor.

A scientific calculator for counting, with pencils and a notebook.
A calculator for counting problems after you can say what is being counted.

This tool counts ordered selections $P(n,k)$, unordered selections $C(n,k)$, or a factorial $n!$. You choose the quantity, enter $n$ and (when needed) $k$, and read an integer or an overflow warning.

The counts are meaningful when you are selecting from $n$ distinct objects, without extra structure such as identical items or forbidden positions. $P(n,k)$ cares about order. $C(n,k)$ does not. $n!$ is $P(n,n)$, the number of ways to line up $n$ distinct objects.

This is not a generating function package and not a proof of a counting identity. It does not handle multisets, it does not solve a recurrence, and it does not replace a sentence that explains what is being counted.

How to use the counters

Pick Combinations, Permutations, or Factorial. Enter a nonnegative integer $n$. For $P$ and $C$, enter $k$ with $0\le k\le n$. The default $n=10$, $k=3$ gives $C(10,3)=120$. Press Compute.

$C(n,k)=n!/(k!(n-k)!)$ counts unordered $k$ sets. $P(n,k)=n!/(n-k)!$ counts ordered $k$ lists. For $n!$ the $k$ box is ignored.

How to read the output

When the integer fits in a double exactly, the page prints it as a count. When $n$ is huge, the page may switch to a rounded value or refuse the run with an overflow message. A rounded $C(n,k)$ is no longer a counting certificate. It is a magnitude.

Use the number only after you can say, in a sentence, what object was counted. “$120$” with no sentence is not combinatorics yet.

Common pitfalls

$n!$ overflows ordinary doubles past $170$. That is a representation limit, not a claim that $171!$ is undefined. The page will warn rather than invent extra digits.

Mixing $P$ and $C$ is the usual homework error. If a prompt says “committees”, order usually does not matter. If it says “passwords” or “lineups”, order usually does. The menu will not infer the story.

These formulas assume distinct objects and no repetition unless you have already encoded repetition by a different model. Sampling with replacement is not $P(n,k)$.

Related reading

Counts become probabilities on the binomial probability calculator and on probability and statistics. Language: probability. Belief updates after a count is observed sit on the Bayes theorem calculator and in Bayes theorem without the fog.

A continuous table is the normal CDF and z score calculator.

Disclaimer. Educational estimate only. This page is not a computer algebra system and not a proof. See the site disclaimer and the FAQ on calculators versus understanding.

Common questions

What is the difference between P(n, k) and C(n, k)?

P counts ordered lists. C counts unordered sets. For the same n and k, P is larger by a factor of k factorial, because each set can be ordered in k factorial ways.

Why does n factorial fail past 170?

IEEE doubles cannot represent 171 factorial exactly, or even finitely in range past a nearby point. The warning is about the computer, not about the integer existing in mathematics.

Does this handle repetition?

Not as a separate mode. The three formulas assume distinct objects and, for P and C, selections without reuse of an item. A different story needs a different count.

What is C(n, 0)?

It is 1. There is one empty selection. The same holds for P(n, 0). The page should agree when k is 0.

Want a tool that matches a new explainer, or a check that a page and a calculator disagree? Write a short note.

Suggest a topic or tool