Calculating of integer logarithm base 2 is pretty easy in near any computer language - you just find the largest '1' in binary representation, and rest becomes
Source: Google Code Jam. https://code.google.com/codejam/contest/10224486/dashboard#s=a&a=1 We're asked to calculate Prob(K successes from N trials) where