#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main(){
int n;
while(cin >> n){
if(n == 0)break;
int prove = 0;
for(int i = 2; i <= sqrt(n); i++)
if(n%i == 0){
prove = 1;break;
}
if(prove == 0){
if(n == 2)cout << "Perfect: 6!" << endl;
else if(n == 3)cout << "Perfect: 28!" << endl;
else if(n == 5)cout << "Perfect: 496!" << endl;
else if(n == 7)cout << "Perfect: 8128!" << endl;
else if(n == 13)cout << "Perfect: 33550336!" << endl;
else if(n == 17)cout << "Perfect: 8589869056!" << endl;
else if(n == 19)cout << "Perfect: 137438691328!" << endl;
else if(n == 31)cout << "Perfect: 2305843008139952128!" << endl;
else cout << "Given number is prime. But, NO perfect number is available." << endl;
}
else cout << "Given number is NOT prime! NO perfect number is available." << endl;
}
return 0;
}
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main(){
int n;
while(cin >> n){
if(n == 0)break;
int prove = 0;
for(int i = 2; i <= sqrt(n); i++)
if(n%i == 0){
prove = 1;break;
}
if(prove == 0){
if(n == 2)cout << "Perfect: 6!" << endl;
else if(n == 3)cout << "Perfect: 28!" << endl;
else if(n == 5)cout << "Perfect: 496!" << endl;
else if(n == 7)cout << "Perfect: 8128!" << endl;
else if(n == 13)cout << "Perfect: 33550336!" << endl;
else if(n == 17)cout << "Perfect: 8589869056!" << endl;
else if(n == 19)cout << "Perfect: 137438691328!" << endl;
else if(n == 31)cout << "Perfect: 2305843008139952128!" << endl;
else cout << "Given number is prime. But, NO perfect number is available." << endl;
}
else cout << "Given number is NOT prime! NO perfect number is available." << endl;
}
return 0;
}
No comments:
Post a Comment