fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. printf("2");
  6. int n;
  7. cin>>n;
  8. for (int i=3; n; i+=2) {
  9. for (int j = 3; j*j<=i ; ++j){
  10. if (i%j==0) goto next;
  11. }
  12. printf(", %d",i);
  13. --n;
  14. next:;
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 16064KB
stdin
10
stdout
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31