3

Suppose I have $n$ numbers $\{1,2,\cdots,n\}$, is there a very quick way of generating $k$-combinations using Mathematica?

Apocalypse
  • 379
  • 1
  • 7

1 Answers1

3

In the answer below n=3 and k=2

Tuples[{1, 2, 3}, 2]

tuples

Compare to SubSets

Subsets[{1, 2, 3}, 2]

subsets

Edit: many thanks to @BobHanlon for suggesting:

Subsets[{1, 2, 3}, {2}]

Blockquote

bmf
  • 15,157
  • 2
  • 26
  • 63