Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int isPrime(int n)
- {
- if (n % 1 || n < 2) return 0;
- if (n % 2==0) return (n == 2);
- if (n % 3==0) return (n == 3);
- float f = (float)sqrt(n);
- for (int i = 5;i <= (int)f; i += 6) {
- if (n % i == 0)
- return 0;
- if (n%(i+2)==0)
- return 0;
- }
- return 1;
- }
- int main(int argc, char *argv[])
- {
- int flag;
- int count = 0;
- int min = atoi(argv[1]);
- int max = atoi(argv[2]);
- for (int i = min; i < max; ++i)
- {
- if (isPrime(i) == 1)
- {
- printf("%d,", i);
- count++;
- }
- }
- printf("\n%d", count);
- return 0;
- }
Add Comment
Please, Sign In to add comment