Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int f(int a)
- {
- int r=0, ha = a/2;
- for(int i=2; a>1 && !r && i <= ha; i++)
- while (a%i==0)
- a /= i, r++;
- return r;
- }
- int main()
- {
- int n,m,k=0,ok=1;
- cin>>n;
- m=n;
- while (n >= 10)
- {
- k++;
- n/=10;
- }
- n=m;
- do{
- n=(n%10)*pow(double(10),k)+n/10;
- cout<<n<<' ';
- if (f(n))
- ok=0;
- }while (n!=m);
- if (ok)
- cout<<"DA"<<endl;
- else
- cout<<"NU"<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment