Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //7. Să se afișeze toate numerele prime mai mici sau egale cu n, care citite invers, sunt tot numere prime.
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int n,cpn,cpnB,numarprim,i,i2,OK,OKP,ogl=0,uc;
- cout<<"n="<<endl;
- cin>>n;
- for (n;n>1;n--)
- {
- cpn=n;
- cpnB=n;
- numarprim=n;
- OK=1;
- OKP=1;
- for (i=2;i<=sqrt(cpn);i++)
- {
- if (cpn%i==0)
- OK=0;
- }
- while (cpnB)
- {
- uc=cpnB%10;
- cpnB=cpnB/10;
- ogl=ogl*10+uc;
- }
- for (i2=2;i<=sqrt(ogl);i++)
- {
- if(ogl%i2==0)
- OKP=1;
- }
- if (OK==1 && OKP==1)
- cout<<numarprim<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement