C++ プログラミングは初めてで、プログラムの 1 つに問題があります
#include <iostream>
using namespace std;
bool IsPerfect(int n);
int main ()
{
for(int i=1; i<100; i++){
IsPerfect(i);
}
return 0;
}
bool IsPerfect(int n){
int sum;
for(int x=1; x<n; x++){
if(n%x==0){
sum+=x;
return true;
cout <<n;
}
else{
return false;
}
}
}
完全数をリストするプログラムを作成しようとしていますが、印刷されない理由に関するバグが見つかりません。