an efficient implementation of n choose k