#27682: _CPP


11030067@mail.hpsh.tp.edu.tw (和平110級鄧雨珊)


#include <iostream>
using namespace std;

int main(){
int n, s;
while (cin >> n){
if (n==0) break;
s=0;
for (int i=1; i<n; i++){
if (n%i==0){
s+=i;
}
}
if (s==n){
cout <<"="<< n <<endl;
continue;
}
int s2=0;
for (int i=1; i<s; i++){
if (s%i==0){
s2+=i;
}
}
if (s2==n){
cout << s <<endl;
}
else {
cout << 0 <<endl;
}
}
}