Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. void ex2()
  2. {
  3. int n;
  4. int i,j;
  5. bool primo;
  6. scanf("%d",&n);
  7. printf("2\n");
  8. for (i=3; i<n; i++)
  9. {
  10. primo = true;
  11. if(i%2 == 0)
  12. {
  13. primo = false;
  14. }
  15. if(primo)
  16. {
  17. for (j=3; (j*j)<=i; j+=2)
  18. {
  19. if((i%j) == 0)
  20. {
  21. primo = false;
  22. }
  23. }
  24. }
  25. if (primo == true) {
  26. printf("%d\n",i);
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement