Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- long long a;
- while (true)
- {
- cin >> a;
- if (a == 0)
- {
- return 0;
- }
- if (a < 3)
- {
- cout << "No such base" << '\n';
- continue;
- }
- if (a == 3)
- {
- cout << 4 << '\n';
- continue;
- }
- long long x1, x2, r = 9999999;
- x1 = a - 3;
- for (int i = 2; i * i <= x1; i++)
- {
- if (x1 % i == 0)
- {
- x2 = x1 / i;
- if (i > 3 && i < r)
- {
- r = i;
- }
- else if (x2 > 3 && x2 < r)
- {
- r = x2;
- }
- }
- }
- if (r == 9999999)
- {
- r = x1;
- }
- cout << r << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment