#Code:
#include<iostream> using namespace std; int main() { int no, i = 1, sum = 0; /* 'endl' insert linefeed like '\n' */ cout << "Check the given number is Perfect Number or not" << endl; cout << "Enter a number:" << endl; cin >> no; /* Loop the process using "while loop" */ while(i < no) { if(no % i == 0) sum += i; i++; } if(sum == no) cout << no << " is a Perfect Number!" << endl; else cout << no << " is not a Perfect Number!" << endl; return 0; }
0 Comment:
Đăng nhận xét
Thank you for your comments!