Write a program to find the Perfect Number in c++ programming
#include<iostream>
using namespace std;
int main(){
int n;
cout<<"Enter the Number ";
cin>>n;
int sum=0;
for(int i=1; i<n; i++){
if(n%i==0){
sum=sum+i;
}
}
if(n==sum){
cout<<"This number "<<n<<" is perfect number"<<endl;
}
else{
cout<<"This number "<<n<<" is not perfect number"<<endl;
}
return 0;
}
Output is :
0 Comments