Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- long double a, a1, r, r1, z, z1, n;
- setprecision(0);
- fixed;
- cin >> a;
- a1 = a / 2;
- r = 0;
- z = 2;
- n = 1;
- r1 = 1;
- z1 = 2;
- while (fmod(a, z) == 0)
- {
- z = pow(z1, n);
- n += 1;
- }
- if (n > r1)
- {
- r1 = n;
- r = z1;
- }
- for (long double i = 3; i < a1; i += 2)
- {
- z = i;
- z1 = z;
- n = 1;
- while (fmod(a, z) == 0)
- {
- z = pow(z1, n);
- n += 1;
- }
- if (n > r1)
- {
- r1 = n;
- r = z1;
- }
- }
- if (r == 0)
- {
- r = a;
- }
- cout << r << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment