int num;
int i = 2;
int j;
String yn;
do {
System.out.print("Enter number : ");
num = input.nextInt();
do{
while (num % i == 0){
j = num/i;
num = j;
System.out.print(i + " ");
if (num % i != 0)
i++;
}
}
while (num % i == 0);
System.out.println();
System.out.println("\nDo you Wish to enter another? (Y/N) : ");
yn = input.next();
}
while (yn.charAt(0) == 'Y');
}
}
if i enter 120 it only outputs 2 2 2 3,
but it needs to output 2 2 2 3 5
what am i doing wrong?
and also how can i println
The Factors are : 2 2 2 3.... a continous output...