So for my assignment, I have to write a program that asks the user for an integer input and then print out that number\'s prime factorization. This is what I have:
Not sure why you are printing the multiplication twice! Here is the cleaned up code:
public static void printPrimeNumbers(int prime) {
int n;
for (int i = 2; i <= prime; i++) {
n = 0;
while (prime % i == 0) {
prime /= i;
n++;
}
if (n != 0) {
for (int j = n; j > 0; j--) {
System.out.print(i);
if (prime != 1) {
System.out.print("*");
}
}
}
}
}