void report() { // report the non-trivial factors System.out.println("All non-trivial factors of the given number " + oddNumber + " are listed as follows: ");
for(int i = 0; i < totalNumberToCheck; i++) { if (factorOrNot == true) { System.out.println( (i+2) + " is a non-trivial factor, and its related factor is: " + (int)(oddNumber/(i+2)) ); } } }
public static void main(String[] args) { int oddnumber = Integer.parseInt(args[0]); // read in the odd number
SeqGeneral sg = new SeqGeneral(oddnumber);
// checks the numbers one by one himself!!! for(int i = 0; i < sg.totalNumberToCheck; i++) sg.factorOrNot = sg.isFactor(i+2); // note: index starts from zero but // the number to check starts from two sg.report(); // reports the result to the princess System.out.println("The hard-working general wins the princess!"); } }
He has alot of soldiers that he can use. I can use the soldiers to do the job using threadgroup.