recon said:
Switching numbers to read backwards is fun. I've never taken a single computer lesson, but I have a sketchy image of how programming works. How did you do the problem though? I don't see how you could have arrived at the solution with the method I mentioned earlier.
I program in the language Java, all I did was the following:
public class program12 {
public static void main(String[] args) {
int number=0, counter=0,trueOrFalse=0;
String firstNum;
firstNum=JOptionPane.showInputDialog("Enter integer: ");
number=Integer.parseInt(firstNum);
trueOrFalse= factorial(number);
System.out.println(trueOrFalse);
}
public static int factorial (int integer)
{
int tens=1,mod=0,value=0,temp=0, counterTens=10,counterOnes=1;
while (mod!=integer){
tens=tens*10;
mod=integer%tens;
}
for (int tenSec=10;tenSec<=tens;tenSec=tenSec*10){
value=(integer%tenSec);
integer=integer-value;
value=value/counterOnes;
value=(value*tens)/counterTens;
temp=temp+value;
counterTens=counterTens*10;
counterOnes=counterOnes*10;
}
return (temp);
}
}
Basically...enter 5321
It counts that it has 4 digits
then does 1000+200+30+5 = 1235