fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n,prim=2;
  6. cin>>n;
  7. while (prim<n){//2<10
  8. int d=2,este_prim=1;
  9. while(d<=prim/2){
  10. if(prim%d==0)
  11. {este_prim=0;
  12. break;}
  13. ++d;
  14. }
  15. if(este_prim==1)
  16. cout<<prim<<" ";//2,3,5,7
  17. prim++;
  18. }
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 5316KB
stdin
10
stdout
2 3 5 7