Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- bool primes(int i)
- {
- int c=0;
- if(i==1)
- return false;
- for(int j=2;j<=pow(i,0.5);j++)
- {
- if(i%j==0)
- c++;
- //cout<<c;
- }
- if(c==0)
- return true;
- else
- return false;
- }
- vector<int> primenum()
- {
- int m,n;
- cin>>m>>n;
- vector<int> v;
- for(int i=m;i<=n;i++)
- {
- bool j=primes(i);
- if(j)
- v.push_back(i);
- //cout<<i<<endl;
- }
- return v;
- }
- int main()
- {
- int n;
- cin>>n;
- vector<vector<int>> m;
- while(n)
- {
- vector<int> p;
- p=primenum();
- m.push_back(p);
- n--;
- }
- for(auto x:m)
- {
- for(auto y:x)
- {
- cout<<y<<endl;
- }
- cout<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement