Advertisement
Guest User

555

a guest
Jan 21st, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. /*5*/
  2. #include <iostream>
  3. #include <cmath>
  4. using namespace std;
  5. int main(){
  6.     int n;
  7.     std::cin >> n;
  8.     if (n <= 0) {  
  9.     cout << "N below or equal zero!" << endl;
  10. } else {
  11.         std::cout << 2 << ' ';
  12.         --n;
  13.         for (int i=3;n;i+=2){
  14.             unsigned sq=sqrt(i);
  15.             bool issimple = true;
  16.             for (unsigned j=2; j <= sq;++j)
  17.                 if (i%j==0) {issimple = false; break;}
  18.             if (issimple) {std::cout << i << ' '; --n;}
  19.         }
  20.    
  21. }
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement