Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int vPrim(int n)
- {
- if(n==2 || n==5 || n==3) return 1;
- if(n%2==0||n%5==0||n%3==0) return 0;
- if(n>5)
- {
- if((n-1)%6==0)
- {
- if(int(sqrt(n))!=sqrt(n)) return 1;
- }
- else if((n+1)%6==0)
- if(int(sqrt(n))!=sqrt(n)) return 1;
- }
- return 0;
- }
- int vPrim2(int n)
- {
- if(n<2) return 0;
- if(n==2) return 1;
- if(n%2==0) return 0;
- for(int d=3;d*d<=n;d+=2)
- if(n%d==0) return 0;
- return 1;
- }
- int main()
- {
- int n, i;
- cin >> n;
- for(i=0;i<=n;++i)
- {
- if(i==1000000||i==10000000||i==100000000||i==500000000||i==800000000) cout << "acum: nr = " << i << " \n";
- if(vPrim(i)!=vPrim(i))
- cout << i << " e gresit \n";
- if(i==n) cout << "Am ajuns la n \n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement