Advertisement
ebx

drugi_kolokvijum_a_prosti

ebx
May 3rd, 2012
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main (int argc, char** argv) {
  5.     int a, b, brojac=0, min, max, i, j, prost=1;
  6.     printf("a= ");
  7.     scanf("%d", &a);
  8.     printf("b= ");
  9.     scanf("%d", &b);
  10.     for (i = a+1; i < b; i++) {
  11.         if (i%2 == 0 || i == 1) continue;
  12.         for (j = 3; j <= sqrt(i); j+=2) {
  13.             if (i%j == 0) {
  14.                 prost=0;
  15.                 break;
  16.             }
  17.         }
  18.             if (prost) {
  19.                 brojac++;
  20.                 if (brojac == 1) min = i;
  21.                 max = i;
  22.             }
  23.         prost=1;
  24.     }
  25.     printf("ukupno prostih: %d\n", brojac);
  26.     if (brojac > 1) {
  27.         printf("min: %d max: %d", min, max);
  28.     }
  29.     getchar();
  30.     getchar(); //System("PAUSE")
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement