I need to invert a number (1234 -> 4321) but in newlisp language.
The code in Java is as follows:
static int invertir(int num,int multiplicador)
{
int inverso=num;
if(num!=0)
{
if(multiplicador==0)
for (multiplicador = 10; (num/multiplicador)>10; multiplicador=multiplicador*10);
inverso=((num%10)*multiplicador)+invertir((num/10) , (multiplicador/10));
}
return inverso;
}
Where your input values are the number to be inverted and a 0. And the code that I have in newlisp is the following:
(define (invertir n m)
(set 'm 10)
(set 'I n )
(if (= m 0)(while (> (/ n m ) 10)(set ('m '(* m 10)))))
(if (!= n 0)
(;incio caso true
set 'I (+ (*(% n 10) m) (invertir (/ n 10)(/ m 10)))
);caso true
I ;caso false
);fin if
I
);fin define
I do not know how to return the value to build the inverse number. I tried it with the number 9123 and the output in newlisp is a 150
Could someone help me?