Traverse all digits from right to left and check if any digit is smaller than previous .
while ( num ) { int digit = num % b ; num /= b ; if ( prev != -1 && digit != prev ) return false ; prev = digit ; } return true ; }