Por ejemplo, si le entregamos el 32, daría:
2 + invertir(3)*10 = 2 + 3*10 = 32
Código:
int invertir (int n)
{
if (n < 10) //caso base
return n;
else
return (n % 10) + invertir (n / 10) * 10;
}
Pero lo hice así y funciona:
Código:
public int invertirNumero(int numero){
if(numero<10){
return numero;
}else{
int contador = 0;
int aux = numero;
while(aux/10!=0){
contador++;
aux = aux/10;
}
return (int)(Math.pow(10, contador))*(numero%10) + this.invertirNumero(numero/10);
}
}