组合与排列生成器

从一组元素生成组合和排列。支持 n 选 k、nPr 及有无重复的排列。

查看指南
设置
选择输入模式、元素、大小 k 及是否允许重复。

元素为 1, 2, 3, … n。最多 20。

不重复时,k 必须 ≤ n。

指南

What does this tool do

The Combination & Permutation Generator produces all possible combinations or permutations from a set of items. Choose items as numbers (1, 2, … n) or enter custom labels (e.g. A, B, C), set the size k, and pick whether order matters (permutation) or not (combination), with or without repetition. Copy results with one click. All generation runs in your browser—no server.

How to use it

  1. Choose input mode — Numbers 1..n uses integers 1 through n; Custom items lets you enter comma-separated labels.
  2. Enter items — For numbers, enter n (1–20). For custom, type items like A, B, C (max 20).
  3. Set size k — How many items per combination or permutation. Without repetition, k must be ≤ n.
  4. Select mode — Combination (order doesn't matter) or Permutation (order matters).
  5. Set repetition — No: each item used at most once. Yes: items can repeat.
  6. Generate — Click to produce the list. Use Copy all to copy results.

How it works

  • Combination without repetition C(n,k) = n!/(k!(n-k)!) — recursive generation of sorted subsets.
  • Combination with repetition C(n+k-1,k) — multisets of size k from n items.
  • Permutation without repetition P(n,k) = n!/(n-k)! — recursive backtracking over remaining items.
  • Permutation with repetition n^k — Cartesian product of k copies of the item set.

Results are capped at 10,000 displayed; beyond that, only the formula and count are shown. All computation runs entirely in your browser. No data is sent to any server.

Use cases & examples

  • Math & homework — Verify combinatorial counts, list all subsets or arrangements.
  • Games & puzzles — Enumerate possible hands, dice rolls, or lock combinations.
  • Sampling — List all ways to choose k items from n for experiments or trials.
  • Passwords & codes — Explore possible PIN or code arrangements (educational only).

Example

  • n=5, k=3, Combination, No repetition → C(5,3) = 10: (1,2,3), (1,2,4), (1,2,5), (1,3,4), (1,3,5), (1,4,5), (2,3,4), (2,3,5), (2,4,5), (3,4,5)
  • A, B, C, k=2, Permutation, No repetition → P(3,2) = 6: AB, AC, BA, BC, CA, CB
  • n=3, k=2, Permutation, Yes repetition → 3² = 9: 11, 12, 13, 21, 22, 23, 31, 32, 33

Limitations & known constraints

  • Max 20 items — n or custom items capped at 20 to prevent browser freeze.
  • Max 10,000 results displayed — For larger counts, only the formula and total are shown.
  • No export — Use Copy all to copy the list; no CSV or file download.

所有计算和转换均完全在您的浏览器中运行。不会向任何服务器发送数据,您的输入不会离开您的设备。