解题思路:
注意事项:
参考代码:
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int N=sc.nextInt();
for(int x=1;x<N;x++) //N以内是完数的数x
{
String temp=" ";
int sum=0;
for(int i=1;i<x;i++) //x的因子
{
if(x%i==0)
{
sum=sum+i;
temp=temp+i+" ";
}
}
if(x==sum)
System.out.println(x+" its factors are"+temp);
}
}
}
0.0分
3 人评分