#include <iostream> #include <vector> #include <cmath> using namespace std; int sumProperDivisors(int n) { if (n == 1) return 0; int sum = 1; // 1 is a proper divisor for any n > 1 int sqrtN = sqrt(n); for (int i = 2; i <= sqrtN; ++i) { if (n % i == 0) { int other = n / i; if (i == other) { sum += i; } else { sum += i + other; } } } return sum; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; while (cin >> n && n != 0) { int sum = sumProperDivisors(n); if (sum == n) { cout << "=" << n << "\n"; } else { int possibleM = sum; if (sumProperDivisors(possibleM) == n && possibleM != n) { cout << possibleM << "\n"; } else { cout << "0\n"; } } } return 0; }