我只需要将因子输出为素数。
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter a number:");
int theNum = keyboard.nextInt();
int i;
System.out.println("\nThe prime factors of " + theNum + " are:");
for(i=1; i <= theNum/2; i++)
if(theNum % i == 0)
{
System.out.print(i + " ");
}
}
}