Yes. Directly check every number by taking one digit at a time, off the right hand side (or some side, but right hand, for now), and comparing it with the base.
We can treat the 21012 number as if it was any suitably sized base, so let's use base 10, just for convenience.
Code:
int num = 21012;
int badnum, remNum, baseNum=2
badnum = 0;
while(num > 0) {
remNum = (num % 10);
//remNum now equals 2 on the first loop, 1 on the second, etc.;
if(remNum >= baseNum) {
badNum = 1;
break;
}
num /= 10; (num = num / 10)
}
which "peels off the most right hand digit, completely, with each loop. Continue looping until num < 1, and if you haven't got a badNumber==1, it's OK.
I haven't run this code, but it's very close. Any errors, let me know.