The missing recursive solution:
int getFirstInt(int input) {
if (input > 0 ? input < 10 : input > -10) {
return input > 0 ? input : -input;
}
return getFirstInt(input / 10);
}
I wouldn't use the ternary operator in real life but - isn't it kind of beautiful? ;)