SHARE
TWEET

Untitled

a guest Apr 18th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /******************************************************************************
  2.  
  3.                               Online C++ Compiler.
  4.                Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15.     int num;
  16.     bool prime=0;
  17.     cin>>num;
  18.     int line=0;
  19.     for (int n=2;n<num;n++)
  20.     {
  21.         prime=1;
  22.         for(int i=2;i<n/2;i++)
  23.         {
  24.             if(n%i==0)
  25.             {
  26.                 prime=0;
  27.                 break;
  28.             }
  29.         }
  30.         if(prime)        
  31.         {
  32.             line++;
  33.             cout<<n<<" ";
  34.             if(line%5==0)
  35.             cout<<endl;
  36.         }
  37.     }
  38.    
  39.  
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top