Josif_tepe

Untitled

May 7th, 2026
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.    
  5.     int n;
  6.     scanf("%d", &n);
  7.    
  8.     int najgolem_zbir = 0;
  9.     int broj;
  10.     for(int i = 1; i < n; i++) {
  11.         int zbir = 0;
  12.        
  13.         for(int j = 1; j <= i; j++) {
  14.             if(i % j == 0) {
  15.                 zbir += j;
  16.             }
  17.         }
  18.        
  19.         if(zbir > najgolem_zbir) {
  20.             najgolem_zbir = zbir;
  21.             broj = i;
  22.         }
  23.        
  24.     }
  25.    
  26.    
  27.     int brojac = 0;
  28.     for(int i = 1; i < n; i++) {
  29.         int zbir = 0;
  30.        
  31.         for(int j = 1; j <= i; j++) {
  32.             if(i % j == 0) {
  33.                 zbir += j;
  34.             }
  35.         }
  36.        
  37.         if(zbir == najgolem_zbir) {
  38.             brojac++;
  39.         }
  40.     }
  41.     printf("Najgolem broj e %d\n", broj);
  42.     printf("Zbir na deliteli: %d\n", najgolem_zbir);
  43.     printf("Ima %d broevi so ist zbir\n", brojac);
  44.     return 0;
  45. }
  46.  
  47.  
  48.  
Advertisement
Add Comment
Please, Sign In to add comment