分解质因数
#include <iostream>
#include <cmath>
using namespace std; int sum(int n)
{
int ans = ; while (n > )
{
ans += n % ;
n /= ;
}
return ans;
} bool work(int n)
{
int i, temp, ans1, ans2; ans1 = sum(n);
temp = n;
i = ;
ans2 = ;
while (i <= sqrt(double(n)))
{
if (n % i == )
{
n /= i;
ans2 += sum(i);
}
else
i++;
}
ans2 += sum(n);
if (ans1 == ans2 && temp != n)
return true;
else
return false;
} int main()
{
int n; //freopen("t.txt", "r", stdin);
while (cin >> n && n != )
{
n++;
while (!work(n))
n++;
cout << n << endl;
}
return ;
}