Advertisement
Josif_tepe

Untitled

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