1 int comb = (1 << k) - 1; 2 while (comb < (1<<n)) { 3 int x = comb & -comb, y = comb + x; 4 comb = (((comb & ~y)/x)>>1) | y; 5 }