ivanakarpuzova

Најголем збир делители

Oct 27th, 2016
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.  
  5.     int n;
  6.     scanf("%d", &n);
  7.     int i;
  8.     int tmp;
  9.     int zbir = 0;
  10.     int maxZbir = 0;
  11.     int j;
  12.     int brojSoMaxZbir;
  13.     for(i = 1; i < n; i++)
  14.     {
  15.         for(j = 1; j < i; j++)
  16.         {
  17.             if(i % j == 0)
  18.                 zbir += j;
  19.         }
  20.         if(maxZbir < zbir)
  21.         {
  22.             maxZbir = zbir;
  23.             brojSoMaxZbir = i;
  24.         }
  25.         zbir = 0;
  26.     }
  27.     printf("%d", brojSoMaxZbir);
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment