#include <iostream>
using namespace std;

int main()
{
 int n,buf,i;
    cout<<"請輸入N:";
 cin>>n;
    cout<<"小於N的完美數有:";
 for(i=1;i<=n;i++){
  buf=0;
  for(int j=1;j<i;j++){
   if(i%j==0)buf=buf+j;
  }
  if(buf==i)cout<<i<<" ";
 }
 cout<<endl;
 system("pause");
 return 0;
}


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 h881068 的頭像
    h881068

    DRGO

    h881068 發表在 痞客邦 留言(0) 人氣()