Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C++ Compiler.
- Code, Compile, Run and Debug C++ program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <iostream>
- using namespace std;
- int main()
- {
- int num;
- bool prime=0;
- cin>>num;
- int line=0;
- for (int n=2;n<num;n++)
- {
- prime=1;
- for(int i=2;i<n/2;i++)
- {
- if(n%i==0)
- {
- prime=0;
- break;
- }
- }
- if(prime)
- {
- line++;
- cout<<n<<" ";
- if(line%5==0)
- cout<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement