fork download
  1. #include <iostream>
  2. #include "math.h"
  3. using namespace std;
  4.  
  5. int main()
  6. {int j,n,i,b;
  7. bool p=true;
  8. while(j!=3) {
  9. cin>>n;
  10. for(b=2;b<sqrt(n);b++){
  11. if(n%b==0){
  12. p=false;
  13. }
  14. }
  15. if(p==true){ for(i=1;i<=n;i+=2){
  16. cout<<i<<" ";}} else {for(i=2;i<=n;i+=2){cout<<i<<" "; }} cout<<"\n"; j++; p=true;
  17. }
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 4316KB
stdin
13
10
5
stdout
1 3 5 7 9 11 13 
2 4 6 8 10 
1 3 5