Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4. #include <math.h>
  5.  
  6. int check_prime (int a);
  7.  
  8. int main (void)
  9. {
  10. int i = 2;
  11.  
  12. printf("2\n3\n");
  13.  
  14. while(1)
  15. {
  16. ++i;
  17. if (check_prime(i)) printf("%d\n", i);
  18. }
  19.  
  20. return 0;
  21. }
  22.  
  23. int check_prime(int a)
  24. {
  25. int j, number;
  26.  
  27. for(j = 2; j < (a / 2) + 1; j++)
  28. {
  29. number = a % j;
  30. if (number == 0) break;
  31. }
  32.  
  33. if (number != 0) return 1;
  34. if (number == 0) return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement