---
# System prepended metadata

title: prime(trial division)
tags: [codebook]

---

---
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);
    }
}
```