Combinations (repetition not allowed & order not important) How to compute a table of numbers (all possibilities), where repetition is not allowed and order is not important.
Example:
I have a set of prime numbers. In this example I have four: {3,5,7,11}, but it can be anything, and I want to choose every pair out of that set.
To make things easier, I want to compute the indices to get those pairs of prime numbers. The set of indices is then {0,1,2,3}. We pick 2 out of 4 elements. So how do we compute the permutations or combinations:
0,1   (3,5)
0,2   (3,7)
0,3   (3,11)
1,2   (5,7)
1,3   (5,11)
2,3   (7,11)

?
It was difficult to find examples on the web, because they either allowed repetitions or were order was important. Pls answer with pseudocode or c/c++ if you can.
You seem interested in just pairs of indices. Then, if you have $n$ elements you can just generate all pairs of indices  $(i,j)$ with $0 \le i &lt; j &lt; n$.
For i=0,1,...,n-2:
   For j=i+1, i+2, ..., n-1:
      Output (i,j)