Functions

for k >= 10, faster than binary search.