fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n,i,j,p=0,c=0,s=2,k,u=2,t;
  5. scanf("%d",&n);
  6. for(i=2;i<n;i++)
  7. {p=0;t=0;
  8. for(j=2;j<i;j++)
  9. {
  10. if(i!=j&&i%j==0)
  11. {
  12. p=1;
  13. break;
  14. }
  15. }
  16. if(p==0)
  17. {s+=i;u=u+s;}
  18. for(k=2;k<u;k++)
  19. {
  20. if(u%k==0)
  21. t=1;
  22. }
  23. if(t==0)
  24. {c++;printf("%d ",u);}
  25. }
  26. printf("%d",c);
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 9432KB
stdin
15
stdout
13 13 2