Skip to content

Instantly share code, notes, and snippets.

@lazyakshay
Created July 26, 2017 06:24
Show Gist options
  • Save lazyakshay/416e8cea95d60e8dd43fbd958c320920 to your computer and use it in GitHub Desktop.
Save lazyakshay/416e8cea95d60e8dd43fbd958c320920 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
int main()
{
//cout << "Hello World!" << endl;
//vector<int> prime;
int n;
cin>>n;
int p=2;
while(p<=n){
int flag=0;
for(int i=2;i*i<=p;i++){
if(p%i==0){
flag=1;
break;
}
}
if(flag==0) cout<<p<<" ";
p++;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment