--- tags: codebook --- {%hackmd theme-dark %} # prime(trial division) ```cpp= #include<vector> #include<cmath> using namespace std; ``` ```cpp= void prime(vector<int>& v,int limit){ vector<int>(1,2).swap(v);//init {2} for(int i=3;i<limit;i++){ bool flag=true; for(int j=0,s=sqrt(i);j<=s;j++) if(!(i%v[j])) flag=false; if(flag) v.push_back(i); } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up