题解 | #质数因子#
质数因子
http://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int calculateNumber = sc.nextInt();
for(int i = 2;i<=calculateNumber;i++)
{
if(calculateNumber%i==0)
{
for(int a=2;a<=i;a++)
{
if(i%a==0&&i!=a)
break;
if(a==i)
{
while(calculateNumber%i==0)
{
calculateNumber/=i;
System.out.print(i+" ");
}
}
}
}
if(i>Math.sqrt(calculateNumber)&&calculateNumber!=1)
{
i=calculateNumber;
System.out.print(i+" ");
break;
}
}
}
}