Josif_tepe

Untitled

Aug 10th, 2025
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     int a, b, k;
  5.    
  6.     scanf("%d%d%d", &a, &b, &k);
  7.    
  8.     int zbir = 0;
  9.     for(int i = a; i <= b; i++) {
  10.         int broj = i;
  11.         int broj_na_deliteli = 0;
  12.        
  13.         for(int j = 1; j <= broj; j++) {
  14.             if(broj % j == 0) {
  15.                 broj_na_deliteli++;
  16.             }
  17.         }
  18.        
  19.         int najmal_prethodnik = broj - k;
  20.         if(najmal_prethodnik < 1) {
  21.             najmal_prethodnik = 1;
  22.         }
  23.        
  24.         int specijalen_broj = 1;
  25.         for(int j = broj - 1; j >= najmal_prethodnik; j--) {
  26.             int deliteli = 0;
  27.            
  28.             for(int l = 1; l <= j; l++) {
  29.                 if(j % l == 0) {
  30.                     deliteli++;
  31.                 }
  32.             }
  33.             if(deliteli >= broj_na_deliteli) {
  34.                 specijalen_broj = 0;
  35.             }
  36.            
  37.         }
  38.        
  39.         if(specijalen_broj == 1) {
  40.             zbir += broj;
  41.         }
  42.        
  43.     }
  44.    
  45.     printf("%d\n", zbir);
  46.    
  47.    
  48.    
  49.     return 0;
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment