Advertisement
Josif_tepe

Untitled

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