No...I was saying that if you enter in a factorion it would tell you if you're right. It was using user input.
I did figure that one out. It need to run through every number incrementally till it found it on it's own.
Feel free to help me slim it down if you see something. My teacher is always commenting on what he calls garbage code.
import javax.swing.JOptionPane;
public class Factorion {
public static void main(String[] args) {
int intNumber;
int number;
int digit;
int total;
int factorial;
intNumber = 0;
while (intNumber <= 40585){
total = 0;
number = intNumber;
do {
digit = number % 10;
factorial = 1;
for (int i = 1; i <= digit; i++) {
factorial *= i;
}
total += factorial;
number /= 10;
} while (number > 0);
if (total == intNumber) {
JOptionPane.showMessageDialog(null, intNumber + " is a Factorion");
intNumber++;
}
else {
System.out.println(intNumber + " is a not Factorion");
intNumber++;
}
}
}
}
This is also the best solution I could come up with for the Factorial program.
import java.math.BigInteger;
public class Factorial {
public static void main(String[] args) {
// BigInteger solution.
BigInteger n = BigInteger.ONE;
for (int i = 1; i <= 100; i++) {
n = n.multiply(BigInteger.valueOf(i));
System.out.println(i + "! = " + n);
}
}
}
Any thoughts?