Counts the number of 2 s in a number at d - th digit
function count2sinRangeAtDigit ( number , d ) { var powerOf10 = parseInt ( Math . pow ( 10 , d ) ) ; var nextPowerOf10 = powerOf10 * 10 ; var right = number % powerOf10 ; var roundDown = number - number % nextPowerOf10 ; var roundup = roundDown + nextPowerOf10 ; var digit = parseInt ( number / powerOf10 ) % 10 ;