# Iterating over all k-element subsets of a finite set.

The problem stated in the title belongs to the class of ‘traditional’ combinatorial problems and it often appears in practice. Let us restate it in more exact terms first:

Given an

`n`

-element set`S`

, enumerate all`k`

-element subset where`k`

is less or equal`n`

.

**Example**: With `S = {1,2,3}`

and `k = 2`

all 2-element subsets are