N Choose K Algorithm