Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main (int argc, char** argv) {
- int a, b, brojac=0, min, max, i, j, prost=1;
- printf("a= ");
- scanf("%d", &a);
- printf("b= ");
- scanf("%d", &b);
- for (i = a+1; i < b; i++) {
- if (i%2 == 0 || i == 1) continue;
- for (j = 3; j <= sqrt(i); j+=2) {
- if (i%j == 0) {
- prost=0;
- break;
- }
- }
- if (prost) {
- brojac++;
- if (brojac == 1) min = i;
- max = i;
- }
- prost=1;
- }
- printf("ukupno prostih: %d\n", brojac);
- if (brojac > 1) {
- printf("min: %d max: %d", min, max);
- }
- getchar();
- getchar(); //System("PAUSE")
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement