def comb_n_range(start_n, stop_n, k):
    c = comb(start_n, k)
yield start_n, c
for n in range(start_n + 1, stop_n):
    c = c * n // (n - k)
yield n, c

def comb_k_range(n, start_k, end_k):
    c = comb(n, start_k)
yield start_k, c
for k in range(start_k + 1, end_k):
    c = c * (n - k + 1) // k
yield k, c
Index into size ordered power set