Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- long long n,i,cnt,LPD;
- while(scanf("%lld",&n)&&n)
- {
- if(n<0)
- {
- n*=-1;
- }
- cnt = 0;
- for(i=2;i*i<=n;i++)
- {
- if(n%i==0)
- {
- cnt++;
- while(n%i==0)
- {
- n/=i;
- }
- LPD = i;
- }
- }
- if(n>1)
- {
- LPD = n;
- cnt++;
- }
- if(cnt>1)
- {
- printf("%lld\n",LPD);
- }
- else
- {
- printf("-1\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment