public class GetPrimeNumeber {
public static void main(String[] args) {
System.out.println("请输入需要被分解的整数n:");
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int k = 2;
boolean flag = true ;
if (n == 2) {
System.out.println("分解质因数过程已经结束!");
return;
}
while (flag) {
if (n % k == 0) {
System.out.println(k);
n = n / k;
if (n % k != 0) {
k++;
if(k>n){
flag = false ;
if(n!=1){
System.out.println(n);
}
}
}
//System.out.println(n);
}else{
k++ ;
if(k>n){
flag = false ;
}
}
}
}
}
public class GetPrimeNumeber {
public static void main(String[] args) {
System.out.println("请输入需要被分解的整数n:");
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int k = 2;
boolean flag = true ;
if (n == 2) {
System.out.println("分解质因数过程已经结束!");
return;
}
while (flag) {
if (n % k == 0) {
System.out.println(k);
n = n / k;
if (n % k != 0) {
k++;
if(k>n){
flag = false ;
if(n!=1){
System.out.println(n);
}
}
}
//System.out.println(n);
}else{
k++ ;
if(k>n){
flag = false ;
}
}
}
}
}