ForHosting KIT · Math

Fundamental counting principle calculator

Three shirts, four pairs of trousers and two pairs of shoes make 24 outfits. Enter how many options each step offers and get the exact number of combinations, even when the answer runs to hundreds of digits. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Stages
3, 4, 2
You get
Total
24
Stages
3
Counts
3, 4, 2
Digits
2

The fundamental counting principle — also called the multiplication rule of counting — says that when a process happens in stages, and each stage offers a fixed number of choices, the total number of possible outcomes is simply the product of those counts. Three shirts, four pairs of trousers and two pairs of shoes make 3 × 4 × 2 = 24 outfits.

What the multiplication rule actually says

Imagine a decision made in several independent steps. At the first step you can pick one of c1 options; whatever you picked, the second step still offers c2 options; the third offers c3, and so on. The fundamental counting principle states that the total number of distinct complete paths through all the steps is c1 × c2 × … × ck.

A restaurant menu with four starters, six mains and three desserts therefore yields 4 × 6 × 3 = 72 different three-course meals. The key assumption is that the number of choices at each stage does not depend on what was chosen before: every branch of the decision tree has the same fan-out at a given level. When that assumption holds, you never need to draw the tree — one multiplication gives you the count.

Exact arithmetic for very large counts

Products grow fast, and that is precisely why counting problems are answered with multiplication rather than enumeration. Ten stages with ten options each already produce ten billion outcomes, and realistic configuration spaces — passwords, license plates, product variants, seating plans — routinely exceed what a 64-bit floating-point number can represent exactly. JavaScript numbers silently lose precision beyond 2^53, which would corrupt a count like 26^10.

This calculator performs the whole product with arbitrary-precision big integers, so every digit in the response is exact, and it returns the total as a decimal string so no client-side number type can mangle it on the way in. The practical limits are generous rather than infinite: up to one thousand stages, each with a count up to one billion.

Count menu or product combinations

Multiply options per category — sizes, colors, finishes — to report how many distinct variants a catalogue really contains.

Size a password or code space

Compute 10^6 for a six-digit PIN or 26^8 for an eight-letter code to reason about brute-force resistance in a security review.

Generate exercises for a math class

Feed random stage counts from a lesson script and get the exact answer key for multiplication-rule problems without manual arithmetic.

What is the fundamental counting principle?

The rule that when a process has stages with c1, c2, ..., ck choices each, the total number of outcomes is the product c1 × c2 × … × ck.

Why is zero rejected as a stage count?

A stage with zero choices means no complete outcome exists. Returning an error instead of a silent zero surfaces what is almost always a modelling mistake.

How big can the result be?

Arbitrarily large within the limits: up to 1000 stages with counts up to 1000000000 each. The total is computed with big integers and returned as an exact decimal string.

Is my input stored?

No. The counts are multiplied in memory and discarded; only the result is returned.

How many combinations does a six-digit PIN have?

Each of the six positions has ten choices, so the count is 10^6, one million codes. Enter six stages of 10 and the calculator multiplies them; an eight-letter code works the same way and gives 26^8.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/math/fundamental-counting-principle

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/math/fundamental-counting-principle \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"stages":[3,4,2]}'
{
  "stages": [
    3,
    4,
    2
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.fundamental_counting_principle",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_stages1000
max_count1000000000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

This API takes an array of per-stage choice counts and returns that product exactly, using big-integer arithmetic so the answer stays precise even when it has hundreds of digits.

What the multiplication rule actually says

This endpoint encodes exactly that rule: you send the stage counts as an array, and it returns the exact product along with the number of stages and the digit length of the result, so you can sanity-check magnitudes at a glance.

Exact arithmetic for very large counts

That covers every textbook exercise and any real configuration space you are likely to script against, while keeping the free browser version instant and the paid API bounded in cost.

Validating your inputs and reading the output

Every stage count must be a positive integer. A zero is rejected — a stage with zero choices makes the whole process impossible, and silently returning zero would hide a modelling mistake — and so are fractions, negative numbers and non-numeric strings. When validation fails, the API responds with an invalid_input error that names the exact offending position, for example stages[2], so a calling script can surface the problem directly. When the input is valid, the response echoes the normalized counts, reports how many stages were multiplied, and gives the total as a decimal string together with its digit count. Use the browser tool on this page to experiment interactively — it runs the very same code as the API — and switch to the API when you need to embed the count in a lesson generator, an inventory system or a test suite. Each API request costs $0.002, with no storage of your data: the numbers are computed and discarded.

What does it cost?

$0.002 per request via the API. It is also free to run in your browser on this page — the same code powers both.

Read the full KIT documentation →