Advertisement
KeeganT

Prime Numbers

Jan 14th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main ()
  6. {
  7.     for(int c=2;c<255;c++)
  8.     {
  9.         bool prime=true;
  10.         for(int x=2;x*x<=c;x++)
  11.         {
  12.             if (c%x==0)
  13.             {
  14.                 prime=false;
  15.                 break;
  16.             }
  17.         }
  18.         if(prime)cout<<c<<endl;
  19.     }
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement