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