Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*5*/
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main(){
- int n;
- std::cin >> n;
- if (n <= 0) {
- cout << "N below or equal zero!" << endl;
- } else {
- std::cout << 2 << ' ';
- --n;
- for (int i=3;n;i+=2){
- unsigned sq=sqrt(i);
- bool issimple = true;
- for (unsigned j=2; j <= sq;++j)
- if (i%j==0) {issimple = false; break;}
- if (issimple) {std::cout << i << ' '; --n;}
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement