Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- const int mx=1e8+123;
- bool is_prime[mx];
- vector<int>v;
- void prime_gen(int n)
- {
- for(int i=3;i*i<=n;i+=2)
- {
- if(is_prime[i]==0)
- {
- for(int j=i*i;j<=n;j+=(i+i))
- {
- is_prime[j]=1;
- }
- }
- }
- v.push_back(2);
- for(int i=3;i<=n;i+=2)
- {
- if(is_prime[i]==0) v.push_back(i);
- }
- }
- int main()
- {
- prime_gen(100000000);
- for(int i=0;i<v.size();i+=100)
- {
- cout<<v[i]<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement